*   >> Lectura Educación Artículos >> science >> programación

Creación de una lista Box

sta. De lo contrario, la cadena se inserta en la lista y la lista está ordenada. El parámetro wParam no se utiliza (ponerlo a NULL). El parámetro lParam es un puntero a la cadena terminada en cero que se va a agregar. El valor de retorno es el índice de cuadro de lista basado en cero de la cadena de agregado. Si se produce un error, el valor de retorno es LB_ERR. Si no hay espacio suficiente para guardar la nueva cadena, el valor de retorno es LB_ERRSPACE. Este tipo de valores de retorno son los identificadores de constantes.

He aquí un programa de ejemplo para crear un cuadro de lista: #include using namespace std; LRESULT CALLBACK MainWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, lParam LPARAM) {switch (uMsg) {default: regresan 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 (y WCX); HWND hwndMain; hwndMain = CreateWindowEx (0, "MainWClass", "Ventana principal", 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 * cadena1 = "la primera cadena."; const char * str2 = "la segunda cadena."; const char * str3 = "la tercera cuerda.

"; const char * STR4 = "la cuarta cuerda."; const char * str5 = "la quinta cuerda."; 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 (y msg, hwndMain, 0, 0)) = 0!) {if (Bret == -1) {//manejar el error y posiblemente salir de la aplicación} else {TranslateMessage (y msg); DispatchMessage (y msg); }} Return msg.

wParam; } Puede utili

Page   <<  [1] [2] [3] >>
Copyright © 2008 - 2016 Lectura Educación Artículos,https://lectura.nmjjxx.com All rights reserved.