Question

Is there a class/example application for a message-only window that is in C++ Win32?

Was it helpful?

Solution

If I recall, the standard solution is to create a basic styleless window with a message pump as you normally would, but never call ShowWindow on it. This way you can receive and process the standard messages like WM_QUERYENDSESSION which are sent to all windows.

OTHER TIPS

From the docs for CreateWindow:

hWndParent [in] Handle to the parent or owner window of the window being created. To create a child window or an owned window, supply a valid window handle. This parameter is optional for pop-up windows.

Windows 2000/XP: To create a message-only window, supply HWND_MESSAGE or a handle to an existing message-only window.

Here is some code, from WebKit I think, that sets up a message-only window for timer events.

Here is an article that shows a (possibly overly) fancy way to create an invisible, message-only window: http://www.codeguru.com/cpp/w-p/win32/tutorials/article.php/c12689

A message-only window is used when you need to process windows messages in a thread, but you don't actually want to display a window on the screen.

For example, if you want to use a Windows timer, but don't have an existing UI window you could latch on to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top