*   >> Lezen Onderwijs artikelen >> science >> programming

Het creëren van Combo Boxes

nde van de lijst. Anders wordt de string in de lijst geplaatst en de lijst wordt gesorteerd. De wParam wordt niet gebruikt (instellen op NULL). De lParam is van het type LPCTSTR en is een verwijzing naar de tekenreeks worden toegevoegd. De return waarde is de op nul gebaseerde index van de reeks in de keuzelijst van de keuzelijst. Als er een fout optreedt, wordt de return waarde is CB_ERR. Als er onvoldoende ruimte beschikbaar is voor de nieuwe snaar slaan, is CB_ERRSPACE.

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

Page   <<  [1] [2] [3] >>
Copyright © 2008 - 2016 Lezen Onderwijs artikelen,https://onderwijs.nmjjxx.com All rights reserved.