Using a dialog box as a main window. Not receiving WM_INITDIALOG messages

490 views Asked by At

I have created a modeless dialog as a main window, but the window procedure isn't being sent WM_INITDIALOG messages.

Here's what I've done.

  1. Created a dialog template using Visual Studio's resource editor, and set its class name to a custom class.
  2. Used WNDCLASSEX to register the class, window procedure, as well as some icons and brush etc.
  3. Used CreateDialog() with the last two parameters set to NULL, (Parent window, and window procedure).
  4. Created the message loop using IsDialogMessage(), TranslateMessage() and DispatchMessage();
  5. Returned DefDlgProc() in the window procedure as the default if no messages were processed.

I can't think of anything else significant. Everything works well except for not receiving WM_INITDIALOG messages. I've done it this way so the app minimises to the task bar, and I can have a menu if needed.

So my first question is, Have I done anything stupid?

Secondly, should I expect to receive WM_INITDIALOG messages using this system? And if not, what is a good way to initialise say a combobox with strings. (I've looked at things like WM_ACTIVATE, WM_ACTIVATEAPP etc, but nothing seems appropriate. And the combobox isn't created yet at WM_CREATE.) Thanks in advance.

1

There are 1 answers

2
Ron Francis On

I realised the answer shortly after posting. As mentioned in the comments above, it's a window procedure, not a dialog procedure, so I shouldn't have been trying to initialize child windows within the procedure.

So I initialized them outside the procedure, after creating the dialog box and before the message loop. All the dialog features are working as expected, but it's a main window that can have a menu and minimizes to the taskbar.