Here's an example of how you can create a table-like structure with 100 lines and one static, one button, and one edit control on each line using the Windows API:
#include <Windows.h>
#define ID_EDIT 1000
#define ID_BUTTON 1001
#define ID_STATIC 1002
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// Register the window class
WNDCLASSEX wc = { 0 };
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszClassName = TEXT("MyWindowClass");
if (!RegisterClassEx(&wc))
{
MessageBox(NULL, TEXT("Failed to register window class!"), TEXT("Error"), MB_OK | MB_ICONERROR);
return 1;
}
// Create the main window
HWND hWnd = CreateWindowEx(0, TEXT("MyWindowClass"), TEXT("Table Example"), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
MessageBox(NULL, TEXT("Failed to create window!"), TEXT("Error"), MB_OK | MB_ICONERROR);
return 1;
}
// Create the controls
for (int i = 0; i < 100; i++)
{
HWND hWndStatic = CreateWindowEx(0, TEXT("STATIC"), TEXT("Static"), WS_CHILD | WS_VISIBLE | SS_CENTER,
0, i * 40, 100, 20, hWnd, (HMENU)(ID_STATIC + i), hInstance, NULL);
HWND hWndEdit = CreateWindowEx(0, TEXT("EDIT"), TEXT("Edit"), WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL,
100, i * 40, 100, 20, hWnd, (HMENU)(ID_EDIT + i), hInstance, NULL);
HWND hWndButton = CreateWindowEx(0, TEXT("BUTTON"), TEXT("Button"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
200, i * 40, 100, 20, hWnd, (HMENU)(ID_BUTTON + i), hInstance, NULL);
}
// Show the main window
ShowWindow(hWnd, nCmdShow);
// Message loop
MSG msg = { 0 };
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
This code creates a total of 300 controls (100 static controls, 100 button controls, and 100 edit controls), each with a unique ID. The controls are created in a loop that iterates 100 times, with each iteration creating one row in the table.
Note that this is just a basic example, and you may need to modify the code to suit your specific needs.