Best way to create a message pump
Hi,
I have a thread and want it to accept windows messages, problem is, the thread has no user interface, hence no message pump. What is the best way to do one, does the following look ok ?
while(true)
{
if (::GetMessage(&m, NULL, WM_BUTTON_RANGE_LOW , WM_BUTTON_RANGE_HI))
{
::TranslateMessage(&m);
::DispatchMessage(&m);
}
}
BTW - this is in a MFC applicaiton DLL.
Regards,
Steve
see my answer to your other thread regarding the processing of non-window oriented msgs.
on NT/2K/XP, you can also create a message-only window if you want to have the msgs dispatched to a particular WindowProc but have no GUI. you do this by specifying HWND_MESSAGE as the parent to your window, either in the CreateWindow/Ex call or via SetParent.
on 9x, you can create a window without making it visible (don''t specify WS_VISIBLE and don''t call ShowWindow) and making it''s width and height = 0 to achieve the same result.
i have no idea how any of this applies to MFC though.
on NT/2K/XP, you can also create a message-only window if you want to have the msgs dispatched to a particular WindowProc but have no GUI. you do this by specifying HWND_MESSAGE as the parent to your window, either in the CreateWindow/Ex call or via SetParent.
on 9x, you can create a window without making it visible (don''t specify WS_VISIBLE and don''t call ShowWindow) and making it''s width and height = 0 to achieve the same result.
i have no idea how any of this applies to MFC though.
Oh snap, what happens if a window''s parent handle is set to be HWND_MESSAGE on 9x systems?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement