Voici un exemple de programme pour créer une zone de liste: #include using namespace std; LRESULT RAPPEL MainWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, lParam LPARAM) {switch (uMsg) {défaut: retour DefWindowProc (hwnd, uMsg, wParam, lParam); } Return 0; } Int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {WCX WNDCLASSEX; 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", "Fenêtre principale", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); si (hwndMain!) return false; ShowWindow (hwndMain, SW_SHOW); UpdateWindow (hwndMain); const char * str1 = "la première chaîne."; const char * str2 = "la deuxième chaîne."; const char * str3 = "la troisième corde.
"; const char * str4 = "la quatrième corde."; const char * STR5 = "la cinquième corde."; HWND hwndLst; hwndLst = CreateWindowEx (0, "LISTBOX", NULL, WS_CHILD, 100, 100, 100, 150, hwndMain, (HMENU) 1, hInstance, NULL); ShowWindow (hwndLst, SW_SHOW); UpdateWindow (hwndLst); SendMessage (hwndLst, LB_ADDSTRING, NULL, (LPARAM) str1); SendMessage (hwndLst, LB_ADDSTRING, NULL, (LPARAM) str2); SendMessage (hwndLst, LB_ADDSTRING, NULL, (LPARAM) str3); SendMessage (hwndLst, LB_ADDSTRING, NULL, (LPARAM) str4); SendMessage (hwndLst, LB_ADDSTRING, NULL, (LPARAM) STR5); Msg MSG; BOOL bRet; while ((bRet = GetMessage (& msg, hwndMain, 0, 0)) = 0!) {if (bRet == -1) {//gérer l'erreur et peut-être quitter l'application} else {TranslateMessage (& msg); DispatchMes