如下代码段, WndProc 哪个case里做处理?wm_command? 还是 wm_notify?
最好贴下case 处理代码。
HWND hListBox=0;
hListBox = CreateWindow(WC_LISTBOX,
NULL,
WS_CHILD|WS_VSCROLL | WS_TABSTOP | LBS_STANDARD
,
x, 23,
100, rcClient.bottom - rcClient.top - 100,
parentWnd, (HMENU)IDC_ListBox,
(HINSTANCE) GetWindowLong(parentWnd, GWL_HINSTANCE),
NULL);
ShowWindow(hListBox,SW_SHOW);
SendMessage(hListBox,LB_ADDSTRING ,0,(LPARAM)"Clear");
SendMessage(hListBox,LB_ADDSTRING ,0,(LPARAM)"你好");
SendMessage(hListBox,LB_ADDSTRING ,0,(LPARAM)"我好");
SendMessage(hListBox,LB_ADDSTRING ,0,(LPARAM)"他好");
处理WM_COMMAND
INT_PTR CALLBACK ListBoxExampleProc(HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
// Add items to list.
HWND hwndList = GetDlgItem(hDlg, IDC_LIST1);
for (int i = 0; i < ARRAYSIZE(Roster); i++)
{
int pos = (int)SendMessage(hwndList, LB_ADDSTRING, 0,
(LPARAM) Roster[i].achName);
// we do not need the rest from Microsoft's example
}
// Set input focus to the list box.
SetFocus(hwndList);
return TRUE;
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
case IDC_LIST1:
{
switch (HIWORD(wParam))
{
case LBN_DBLCLK:
{
HWND hwndList = GetDlgItem(hDlg, IDC_LIST1);
// Get selected index.
int lbItem = (int)SendMessage(hwndList, LB_GETCURSEL, 0, 0);
// display item's text
TCHAR buff[MAX_PATH];
SendMessage(hwndList, LB_GETTEXT, lbItem, (LPARAM)buff);
SetDlgItemText(hDlg, IDC_EDIT1, buff);
return TRUE;
}
}
}
return TRUE;
}
}
return FALSE;
}
示例如下:
注释很清楚。
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_LIST:
// It's our listbox, check the notification code
switch(HIWORD(wParam))
{
case LBN_SELCHANGE:
// Selection changed, do stuff here.
break;
}
break;
// ... other controls
}
break;