*   >> Leitura Educação Artigos >> science >> programação

Criando uma lista Box

arâmetro wParam não é usado (defini-lo como NULL). O parâmetro lParam é um ponteiro para a string terminada em null que está a ser adicionado. O valor de retorno é o índice de caixa de lista baseado em zero da seqüência acrescentou. Se ocorrer um erro, o valor de retorno é LB_ERR. Se não houver espaço suficiente para armazenar a nova seqüência, o valor de retorno é LB_ERRSPACE. Esses tipos de valores de retorno são identificadores para constantes.

Aqui está um exemplo de programa para criar uma caixa de listagem: #include using namespace std; LRESULT CALLBACK MainWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {switch (uMsg) {default: voltar 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", "janela principal", 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 = "a primeira string."; const char * str2 = "segunda corda."; const char * str3 = "a terceira corda.

"; const char * str4 = "a quarta corda."; const char * str5 = "a quinta corda."; 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) {//processar o erro e, possivelmente, sair do aplicativo} else {TranslateMessage (& msg); DispatchMessage (& msg); }} Retornar msg.

wParam; } Você pode usar o comando a seguir no prompt de comando para compilar o código: g ++ winlst.cpp -mwin

Page   <<  [1] [2] [3] >>
Copyright © 2008 - 2016 Leitura Educação Artigos,https://artigos.nmjjxx.com All rights reserved.