Link to home
Start Free TrialLog in
Avatar of OleSetnes
OleSetnes

asked on

Create a dialog inside a frame window

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.
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

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.
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.
@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...
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. :)
Well as the section on the wizard is called 'generated classes' ...
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.
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
Avatar of OleSetnes
OleSetnes

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It wasn't exactly what I was asking about - but it turned out that I could use the suggested solution instead.