views:

1703

answers:

7

Hello, would anyone know of a class/example application for a message only window that is in c++ win32?

Thank you Micheal Weller! I took the code for a standard window in c++ and commented out the show window and it works like a charm! Thanks again!

A: 

Can you clarify what you mean exactly? This article shows you how to make a C++ class that encapsulates a window and handles the window messages in an object-oriented manner. Is that what you're looking for?

Adam Rosenfield
+1  A: 

If all you need is a simple modal message dialog with an "OK" button or "Yes"/"No" buttons, try the handy Win32 MessageBox function. It's documented here on MSDN.

MattK
Sounds like what he means.
jmucchiello
A: 

A message only window is used when you need to process windows messages in a thread but 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.

Daemin
+1  A: 

I can't code at the moment (dammit), but 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.

Mike Weller
+4  A: 

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

Dave Ray
A: 

See Win32 api ng news://comp.os.ms-windows.programmer.win32

This has just been posted >500 times for 20 years (!)

And I don't talk about MSDN, with dozens of samples !

A: 

Refer Win32 Programming book by Charles Petzold

Vinay