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
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.
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.