Se o espaço for insuficiente para armazenar a nova seqüência, é CB_ERRSPACE. Aqui está um exemplo de programa para criar uma caixa de listagem simples: #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 hwndCb; hwndCb = CreateWindowEx (0, "Caixa de combinação", 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) {//processar o erro e, possivelmente, sair do aplicativo} else {Tr