答案 0 :(得分:1)
单击Win32按钮时,它将向其父窗口发送BN_CLICKED
通知,该消息中包含按钮的HWND和ID。在父窗口的wndproc中,您可以捕获通知并为发送通知的任何按钮调用所需的任何函数。
case WM_COMMAND:
{
if ((HIWORD(wParam) == BN_CLICKED) && (lParam != 0))
{
switch (LOWORD(wParam))
{
case ID_BTN1:
Function_B1();
break;
case ID_BTN2:
Function_B2();
break;
}
}
break:
}
或
case WM_COMMAND:
{
if ((HIWORD(wParam) == BN_CLICKED) && (lParam != 0))
{
HWND hwndBtn = (HWND) lParam;
if (hwndBtn == hwndBtn1)
Function_B1();
else if (hwndBtn == hwndBtn2)
Function_B2();
}
break:
}
答案 1 :(得分:0)
谢谢你,雷米。 我只是对switch语句有疑问:
case WM_COMMAND:
{
switch (wmId)
{
case 1:
Function_B1(hWnd, wParam, lParam);
break;
case 2:
Function_B2(hWnd, wParam, lParam);
break;
case 3:
Function_B3(hWnd, wParam, lParam);
break;