如何在 ListBox 中选择的 MessageBox 文本中显示?我尝试使用下一个代码,但它只显示空白 MessageBox
wchar_t listBoxStr[15];
HWND hWndList;
switch (message)
{
case WM_CREATE:
hWndList = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("listbox"), "", WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_AUTOVSCROLL, 240, 40, 150, 20, hwnd, (HMENU)105, NULL, NULL);
SendMessage(hWndList, LB_ADDSTRING, 0, (LPARAM)"name");
SendMessage(hWndList, LB_ADDSTRING, 0, (LPARAM)"extension");
SendMessage(hWndList, LB_ADDSTRING, 0, (LPARAM)"date");
SendMessage(hWndList, LB_ADDSTRING, 0, (LPARAM)"size");
CreateWindowEx(NULL, TEXT("button"), TEXT("FIND"), WS_VISIBLE | WS_CHILD, 410, 40, 50, 20, hwnd, (HMENU)106, NULL, NULL);
return 0 ;
return 0 ;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case 106:
SendMessageW(hWndList, LB_GETTEXT,0,(LPARAM)listBoxStr);
MessageBoxW(NULL, listBoxStr, L"", NULL);
return 0;
}
return 0;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps);
GetClientRect (hwnd, &rect) ;
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}