MDI Programming 
Author Message
 MDI Programming

Hello,

I am writing a MDI program, and it is my first attempt at using the MFC
document/view architecture. Anyway, when I was beginning the program
with the AppWizard, I told it to make the view of type CFormView, so
that I could have something like a dialog in the MDI application. But
this makes all the views the same dialog resource. I don't even need the
document part, and I already got rid of the new/open/save file stuff.
Basically what I want to write is one program that has a main dialog
View, and then say they press a settings button, then it shows a child
CFormView as the view with a different dialog resource for settings. All
I can get it to do is show the same CFormView dialog as the view, how
can I make my own windows for it to show, I already have the dialogs
made, I just want different ones to show, not just the same one. I hope
you understand my meaning. I have a few books on MFC, but none go into
this type of thing. It was easy in VB, but how in VC?

It is just the same as creating multiple Dialog apps, and then
containing them all in one Main Window.

            Thanks!
            Ryan Kelley



Mon, 09 Jul 2001 03:00:00 GMT  
 MDI Programming
I hope you get some more answers than this one,
cause I believe there should be more ways of doing
this. Also, there is more details that may have to
be considered (like sharing menus and so on).

First you must create a CFormView derived class for
each dialog resource.

Then register all these classes in your app
(InitInstance), copying the code for the
AddDocTemplate stuff. You can use the same document
class for all views if you like.

I believe there is an easier way to create views,
but the following suits my needs:

        POSITION pos=GetFirstDocTemplatePosition();
        CDocument *pDoc=NULL;
        int i;
        for (i=0; i<=ix; i++) Get the desired template
                pDT=GetNextDocTemplate(pos);
        CFrameWnd * pFrame;

pDT->InitialUpdateFrame(pFrame=pDT->CreateNewFrame(pDoc=pDT->CreateNewDocument(),
NULL), pDoc);

/Glenn

Quote:

> Hello,

> I am writing a MDI program, and it is my first attempt at using the MFC
> document/view architecture. Anyway, when I was beginning the program
> with the AppWizard, I told it to make the view of type CFormView, so
> that I could have something like a dialog in the MDI application. But
> this makes all the views the same dialog resource. I don't even need the
> document part, and I already got rid of the new/open/save file stuff.
> Basically what I want to write is one program that has a main dialog
> View, and then say they press a settings button, then it shows a child
> CFormView as the view with a different dialog resource for settings. All
> I can get it to do is show the same CFormView dialog as the view, how
> can I make my own windows for it to show, I already have the dialogs
> made, I just want different ones to show, not just the same one. I hope
> you understand my meaning. I have a few books on MFC, but none go into
> this type of thing. It was easy in VB, but how in VC?

> It is just the same as creating multiple Dialog apps, and then
> containing them all in one Main Window.

>             Thanks!
>             Ryan Kelley



Tue, 10 Jul 2001 03:00:00 GMT  
 MDI Programming
I have read up on doing this, I seem to have a general understaning. I
guess I can call AddNewDocTemplate, and point it to a different class with
a different CFormView. However, this is just my guess, and I have to work
all weekend so I wont get to try it until Monday. I hope that Microsoft
adds better functionality for this in future versions of MFC.



Quote:
> I hope you get some more answers than this one,
> cause I believe there should be more ways of doing
> this. Also, there is more details that may have to
> be considered (like sharing menus and so on).

> First you must create a CFormView derived class for
> each dialog resource.

> Then register all these classes in your app
> (InitInstance), copying the code for the
> AddDocTemplate stuff. You can use the same document
> class for all views if you like.

> I believe there is an easier way to create views,
> but the following suits my needs:

>    POSITION pos=GetFirstDocTemplatePosition();
>    CDocument *pDoc=NULL;
>    int i;
>    for (i=0; i<=ix; i++) Get the desired template
>            pDT=GetNextDocTemplate(pos);
>    CFrameWnd * pFrame;

pDT->InitialUpdateFrame(pFrame=pDT->CreateNewFrame(pDoc=pDT->CreateNewDocume
nt(),

- Show quoted text -

Quote:
> NULL), pDoc);

> /Glenn


> > Hello,

> > I am writing a MDI program, and it is my first attempt at using the MFC
> > document/view architecture. Anyway, when I was beginning the program
> > with the AppWizard, I told it to make the view of type CFormView, so
> > that I could have something like a dialog in the MDI application. But
> > this makes all the views the same dialog resource. I don't even need
the
> > document part, and I already got rid of the new/open/save file stuff.
> > Basically what I want to write is one program that has a main dialog
> > View, and then say they press a settings button, then it shows a child
> > CFormView as the view with a different dialog resource for settings.
All
> > I can get it to do is show the same CFormView dialog as the view, how
> > can I make my own windows for it to show, I already have the dialogs
> > made, I just want different ones to show, not just the same one. I hope
> > you understand my meaning. I have a few books on MFC, but none go into
> > this type of thing. It was easy in VB, but how in VC?

> > It is just the same as creating multiple Dialog apps, and then
> > containing them all in one Main Window.

> >             Thanks!
> >             Ryan Kelley



Tue, 10 Jul 2001 03:00:00 GMT  
 MDI Programming
This is complicated and not very well documented.  Your best bet is
The MFC Answer Book by Kain, pub. Addison Wesley.
Quote:

>Hello,

>I am writing a MDI program, and it is my first attempt at using the MFC
>document/view architecture. Anyway, when I was beginning the program
>with the AppWizard, I told it to make the view of type CFormView, so
>that I could have something like a dialog in the MDI application. But



Tue, 10 Jul 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Changing Dynamicaly view in an MDI program

2. MDI Programming

3. class/file connection in an MDI program

4. topmost view in MFC MDI program, how to ?

5. Simulate the File - New... command in mdi programs

6. MFC SDI and MDI Programming Books

7. How to add scroll bars to a mdi program child form

8. Multiple CToolbars with MDI program

9. Focus in an MDI program

10. Dynamic Menus in MDI program

11. Child window flicker in MDI program

12. Multiple Child frames in MDI program

 

 
Powered by phpBB® Forum Software