Hier is een voorbeeld programma om een eenvoudige keuzelijst te maken: #include using namespace std; LRESULT CALLBACK MainWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {schakelaar (uMsg) {default: terug DefWindowProc (hwnd, uMsg, wParam, lParam); } Return 0; } Int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {WNDCLASSEX wcx; wcx.cbSize = sizeof (wcx); wcx.style = CS_HREDRAW | CS_VREDRAW; wcx.lpfnWndProc = MainWndProc; wcx.cbClsExtra = 0; wcx.cbWndExtra = 0; wcx.hInstance = hInstance; wcx.hIcon = NULL; wcx.
hCursor = LoadCursor (NULL, IDC_ARROW); wcx.hbrBackground = (HBRUSH) (COLOR_BACKGROUND + 1); wcx.lpszMenuName = NULL; wcx.lpszClassName = "MainWClass"; wcx.hIconSm = NULL; RegisterClassEx (& wcx); HWND hwndMain; hwndMain = CreateWindowEx (0, "MainWClass", "hoofdvenster", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); if (hwndMain!) return false; ShowWindow (hwndMain, SW_SHOW); UpdateWindow (hwndMain); const char * str1 = "de eerste string."; const char * str2 = "de tweede string."; const char * str3 = "de derde snaar.
"; const char * str4 = "de vierde snaar."; const char * STR5 = "de vijfde snaar."; HWND hwndCb; hwndCb = CreateWindowEx (0, "combobox", NULL, WS_CHILD | CBS_SIMPLE, 100, 100, 100, 150, hwndMain, (HMENU) 1, hInstance, NULL); ShowWindow (hwndCb, SW_SHOW); UpdateWindow (hwndCb); SendMessage (hwndCb, CB_ADDSTRING, NULL, (LPARAM) str1); SendMessage (hwndCb, CB_ADDSTRING, NULL, (LPARAM) str2); SendMessage (hwndCb, CB_ADDSTRING, NULL, (LPARAM) str3); SendMessage (hwndCb, CB_ADDSTRING, NULL, (LPARAM) str4); SendMessage (hwndCb, CB_ADDSTRING, NULL, (LPARAM) STR5); MSG msg; BOOL Bret; while ((Bret = GetMessage (& msg, hwndMain, 0, 0)) = 0!) {if (Bret == -1) {//omgaan met de fout en de toepassing mogelijk af te sluiten} else {TranslateMessage (& msg); DispatchMessage (& msg); }} Terug msg.
wParam; } U kunt de volgende opdracht bij de opdrachtprompt om de code