Create a dialog inside a frame window

OleSetnes
OleSetnes used Ask the Experts™
on
Hi,
I want to create a frame window with a dialog as the client window. I'm not talking about having a dialog as the main window in an application. The frame window should have an icon, could be resize by pulling the edges, be modeless and have minimize and close buttons.

Something like this:

CDialog* pMyDialogClient = new CDialog(...);
CFrameWnd* pMyFrame = new CFrameWnd(.., pMyDialogClient, ...);
pMyFrame->SetIcon(...);
pMyFrame->Create(...);
pMyFrame->Show(SW_SHOW);

I not very familiar with MFC but I have done this in other frameworks where it have been quite easy.  Perhaps I'm looking at the wrong classes in MFC because it is not obvious for me how to set the client dialog for the CFrameWnd class.

Thank you, Ole.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
AndyAinscowFreelance programmer / Consultant

Commented:
Choose SDI as the new project type.  Then have a look at the classes to be generated and change base class of the View (CXYZView or whatever it is called) from CView into CFormView.

Now you have a 'dialog' inside a frame window.
Janusz CzopowikSenior Software Engineer

Commented:
Actually you can specify CFormView class as a base class of the view, while creating project. Depending on the version of the visual studio, you just have to navigate to the last page, or choose last link on app wizard dialog and select CFormView from the combo.
This will create dialog resource necessary for the form view. Replacing class name is not enough.
AndyAinscowFreelance programmer / Consultant

Commented:
@JohnCZ
>>Replacing class name is not enough.

Did you not read my comment closely enough?
...Then have a look at the classes to be generated and change base class...
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Janusz CzopowikSenior Software Engineer

Commented:
Yes I have, but I was under impression that by "generated classes" you meant classes after project is generated.
I think you should have stated it more precisely to avoid misinterpreting by readers especially by some who are not really familiar with app wizard interface. :)
AndyAinscowFreelance programmer / Consultant

Commented:
Well as the section on the wizard is called 'generated classes' ...
Janusz CzopowikSenior Software Engineer

Commented:
Yes that is true but nowhere in your post have I seen mentioning of the app wizard. That is why the confusion.
Besides some people are still using VS 6.0 and class wizard interface is completely different.
AndyAinscowFreelance programmer / Consultant

Commented:
Choose SDI as the new project type.  That starts the wizard.  Even with VS6 it still showed the classes to be generated as part of the options

Author

Commented:
Hi,
As I wrote in my question I'm not talking about having a dialog as the main window in an application.

I did try to create an SDI application to see if it would give me some hints to how to do this. But it just creates an application class derived from CWinApp and the it creates a dialog in InitInstance():
CTestDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();

I would like to have a modeless dialog on the desktop with an Icon in the upper left corner and it should be possible to minimize it to the task bar etc. This modeless dialog should be used to show status information independently of what the main application window is doing.

Btw. I'm using VS2010.

Thanks, Ole
Freelance programmer / Consultant
Commented:
Have a check at:
http://www.experts-exchange.com/Programming/System/Windows__Programming/MFC/A_3831-Sudoku-a-complete-MFC-application-Part-11.html

That shows how to create and use a modeless dialog.  If you want it to resize then you will need to modify the dialog resource - note MFC does NOT automatically resize or move controls on a dialog as the dialog is resized.

Author

Commented:
It wasn't exactly what I was asking about - but it turned out that I could use the suggested solution instead.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial