earliest WM_??? event where HWND already exist

Hi All,

I have a problem with Window dialog creation to be able to register my event handlers to my HWND.
I would like to find the earliest! WM_ command where the Window/Dialog initiated/created so i will have the proper and "final" HWND to which I can regiter my custom event handlers

WM_CREATE and WM_INITDIALOG do not work!


Thanks
Last edited on
According to http://msdn.microsoft.com/en-us/library/windows/desktop/ms632619(v=vs.85).aspx , the WM_CREATE message is sent after the window is created, and therefore the HWND should be valid.

According to http://msdn.microsoft.com/en-us/library/aa931243.aspx , the WM_INITDIALOG message is sent just before displaying the dialog in order to initialize child controls. To create a child control, a parent window is needed. Therefore, the HWND is also valid.

Why do you say they don't work?
Possible the code on my side is wrong and this is why above mentioned WM_ messages don't work for me..

thanks

I have a problem with Window dialog creation to be able to register my event handlers to my HWND.


In any case, event handlers need to be related to a window class through the lpfnWndProc member of WNDCLASSEX rather than to a HWND. There can be and oftentimes is a one to many relationship between a Window Class (and the associated event handlers for windows of that class) and windows of that class - each with a different HWND, but of the same class.
I am unclear about your original problem. Under normal circumstances, creating a modeless dialog using CreateDialog, your event handlers (in your DialogProc) should be called automatically. So I don't really understand what you mean by custom event handlers in this context.

Or are you trying to use a dialog as your top level window with a WindowProc?

In that case you need to register your class with DLGWNDEXTRA, add the class to your dialog resource, call CreateDialog with NULL for the DialogProc, and use a WindowProc rather than a DialogProc (which passes unhandled calls to either DefWindowProc or DefDlgProc.).

Note that WM_INITDIALOG is not sent in this case; just WM_CREATE. But if you want to follow the standard dialog sequence, you could always post yourself a custom message from you WM_CREATE handler.
Last edited on
Topic archived. No new replies allowed.