Reputation: 13
I am writing some library with using WIN API. I have a problem with receiving WM_NOTIFY message from WC_TABCONTROL class window in parent window WinProc function. I check by "debug prints", that parent of child was set correctly. I receives WM_COMMAND messages and correctly in some function. I have not idea what can be a reason for this. Tab control in window looks good and responds for mouse clicks with do visual tab item select change.
for example, when I click to unselected tab, I receive following messages http://pastie.org/6571509
You can check my WIN Proc function here http://goo.gl/knJ4Z , line 346.
Create tab control:
ps_ext->d_handle = CreateWindowExW(0, // no extended styles
WC_TABCONTROL, // class name
L"", // default text
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, // overlapped window
CW_USEDEFAULT, // default horizontal position
CW_USEDEFAULT, // default vertical position
CW_USEDEFAULT, // default width
CW_USEDEFAULT, // default height
HWND_MESSAGE, // no parent or owner window
(HMENU)WINSEM_Window_NextComponentID(), // class menu used
WINSEM_Window_hInstance,// instance handle
(LPVOID)&ps_ext->s_window); // no window creation data
After it, set correct parent by SetParent function call. Tab is resized by something like:
uFlags = SWP_NOOWNERZORDER | SWP_NOZORDER;
if (SetWindowPos(ps_window->d_handle, NULL, s0_x, s0_y, s0_w, s0_h, uFlags)==0)
{
DWORD dErr;
dErr = GetLastError();
HaveWinLastError_Error(ps_pack, WINSEM_WINDOW_fromerror_windowPos+0, dErr, dErr);
break;
}
And showing window and clicking on tab control don't generate WM_NOTIFY message received by parent window winProc function.
This is my message receive code:
bRet = PeekMessage( &msg, NULL, 0, 0, PM_REMOVE);
if (bRet==FALSE)
{
// no messages received
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Have anybody any idea about this problem? Thanks for you ideas and time.
Upvotes: 0
Views: 324
Reputation: 37132
I suspect that the tab control caches its parent window when it is created and never updates it. If you re-parent it, the messages will still go to the original parent - which is an invalid window in this case.
Why are you creating it with HWND_MESSAGE
as a parent anyway? Why not just create it with its proper parent to begin with?
Upvotes: 3