Associate a dialogue to a window

I got through the "Hello World" example of Win32 from however there is still something that I am missing.

My resource file has an icon, a menu and a dialogue. I can associate the icon and the menu to my WinMain using this:
wc.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_ICON1));
wc.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON,16,16,0);

When I run the program, I have a box with a white background. How do I associate my dialogue resource with this window?

I'm guessing I need to do this: wc.cbWndExtra = DLGWINDOWEXTRA;. But that still doesn't associate my dialogue resource (IDD_FORMVIEW).
If your main window is a dialog, you would want to create it with either the CreateDialog function (for a modeless dialog) or the DialogBox() function (for a modal dialog). You do not want to use CreateWindow.

Dialogs behave differently from normal windows.
Last edited on
Is it possible to put a menu object in a Dialogue? I don't see an option for this.

Regardless it seems strange that you can't populate a Window with anything such as buttons or boxes. Perhaps I just have my nomenclature wrong. What kind of a resource would you add to put a button, text box or anything like that in the main window? I was using the Dialog resource in VS2010 because I don't know of any other type.
Yes, a dialog can have a menu, created with resource editor.

Topic archived. No new replies allowed.