views:

185

answers:

1

I created an SDI MFC app without the doc/view support. The MFC template gives me an app with a blank window (And a menu, etc)

I want to show my CFormView object on that main window. (Based on a dlg made in the gui editor)

How do I do that? CreateWindow and showwindow don't seem to be all that is needed. All the web pages I find seem to talk about MDI and other stuff that is not in my app.

  • This view is never going to change. It will have one list box control on it and that is all. How do I get a new form view to appear?

  • Additionally, how do I get a floating window with one control on it to appear as well? (DLG boxes and DoModal() will not work for me here.)

+1  A: 
  • Give your CFormView the WS_CHILD style
  • Create it as a MODELESS dialog with the app window as the parent window
  • resize it to fit the parent's client area, or resize the parent to fit it.

The WS_CHILD style is not a default style for a dialog template, but you can add it. this will cause the dialog to show up inside the client area of the main frame window you when create it.

You may also want to add a call to IsDialogMessage() to your message pump. This is needed get the TAB key to behave the way you expect it do in a dialog.

Edit ---- I'm not an MFC programmer, so I can only guess how you would go about this in MFC.

Presumably you still have dialog templates, so you would go into your .RC file and remove the WS_POPUP and add the WS_CHILD style to your template declaration. like this:

IDD_WHATEVER DIALOG DISCARDABLE  0, 0, 275, 217
STYLE DS_MODALFRAME | DS_3DLOOK | WS_CHILD | WS_VISIBLE
CAPTION "General"
FONT 8, "MS Sans Serif"
BEGIN
   // etc
END

Modeless dialogs are created in Win32 by using CreateDialog rather than DialogBox, in MFC by using Create() rather than DoModal().

John Knoeller
thanks - I'll try that. I am not sure how to do the steps you mention though.
Tim