tabs
窗口是按钮的父窗口,所以当按钮被点击时,按钮会向窗口发送WM_COMMAND/BN_CLICKED
通知。tabs
您必须tabs
通过其中一个子类化窗口SetWindowLongPtr(GWL_WNDPROC)
或SetWindowSubClass()
接收该消息。例如:
WNDPROC prevWndProc;
LRESULT CALLBACK myWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if ((uMsg == WM_COMMAND) && (HIWORD(wParam) == BN_CLICKED))
{
// LOWORD(wParam) is the ID, and lParam is the HWND,
// of the button that was clicked. do something ...
}
return CallWindowProc(prevWndProc, hWnd, uMsg, wParam, lParam);
}
tabs = CreateWindowEx(0, WC_TABCONTROL, 0, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 0, 0, rc.right + 2, rc.bottom - 22, hwnd, NULL, instance, NULL);
prevWndProc = (WNDPROC) SetWindowLongPtr(tabs, GWLP_WNDPROC, (LONG_PTR) &myWndProc);
或者:
LRESULT CALLBACK mySubClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
if ((uMsg == WM_COMMAND) && (HIWORD(wParam) == BN_CLICKED))
{
// LOWORD(wParam) is the ID, and lParam is the HWND,
// of the button that was clicked. do something ...
}
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}
tabs = CreateWindowEx(0, WC_TABCONTROL, 0, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 0, 0, rc.right + 2, rc.bottom - 22, hwnd, NULL, instance, NULL);
SetWindowSubclass(tabs, &mySubClassProc, 0, 0);