CHILD MDI -
Ehab Bassilli -- ehab@total.net
Friday, March 28, 1997
Environment: VC++ 5.0, Win 95
I need to create an MDI where the user has a number of CHILD documents that
can be created based
upon their initial selection from the FILE menu..
eg.
FILE EDIT VIEW ...
->dialog one
->dialog two
->dialog etc..
I need the children (kids) to be dialog based..
I know, well, I suppose that the class for the viewtype shuld be set to :
CFormView...
OK.. then what? I need to create different forms/dialogs that should be
treated as
children documents of the MDI...
Please please help
Ehab Bassilli..
ehab@total.net
Paul -- paulstemper@mpl1.ra.rockwell.com
Monday, March 31, 1997
Ehab,
MFC-L is intended for advanced questions on MFC. I am assuming that you
believe your question is advanced because you can't get AppWizard to do
everything for you.....
I have written a app that does basically what you want. I will eMail it
to you separately so I don't bog down the mailing list.. (If anyone else
would care for it, please let me know.)
[Moderator's note: Paul emailed it to me, and I put it up on the
web site. http://www2.vertexgroup.com/mfc-l/dumbapp.zip ]
Anyway, these are the steps I went through to create the sample app.
1) Use AppWizard to create a default MDI app. (Don't change any
selections unless you WANT to.)
2) Create three new dialog resources. (YES, we are going to use CformView
classes. This should be equivalent to your requirement of being dialog
based views.)
3) Use ClassWizard to create three new classes based upon CFormView. (I
called my classes Form1, Form2, and Form3.) When you create each class,
you tell class wizard the dialog template to tie to each class.
4) Here comes the tricky part. You can't use ClassWizard. You must code
by hand!! (Oh No!.) At the top of you App class (mine is CDumbAppApp,)
put the includes for each of your CFormView classes. My example is
#include "Form1.h", #include "Form2.h", & #include "Form3.h"
5) Final tricky part. In you InitInstance in the App class, locate the
lines which register the document templates. It should look something
like this:
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_DUMBAPTYPE,
RUNTIME_CLASS(CDumbAppDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CDumbAppView));
AddDocTemplate(pDocTemplate);
Change the line that says: RUNTIME_CLASS(CDumbAppView)); to
RUNTIME_CLASS(Form1));
Add two more MultiDocTemplates for the other two view types. The final
chunk should look like this:
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_DUMBAPTYPE,
RUNTIME_CLASS(CDumbAppDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(Form1));
AddDocTemplate(pDocTemplate);
pDocTemplate = new CMultiDocTemplate(
IDR_DUMBAPTYPE2,
RUNTIME_CLASS(CDumbAppDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(Form2));
AddDocTemplate(pDocTemplate);
pDocTemplate = new CMultiDocTemplate(
IDR_DUMBAPTYPE3,
RUNTIME_CLASS(CDumbAppDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(Form3));
AddDocTemplate(pDocTemplate);
When you do a file-new with more then 1 document template registered, MFC
will automatically pop up a dialog to ask you which type you want. You
can customize each document type name by changing the string resource
that you pass as the first parameter to the CMultiDocTemplate. I don't
wish to explain any more then to say, "Read the documentation!" Check on
CMultiDocTemplate. I know your original posting said you wanted to pick
the document type off of the file-new menu, and this example does not do
that. It is pretty trival to change it, but I wanted to show that I
could do even this much using almost nothing but ClassWizard.
People, this is supposed to be an advanced MFC mailing list. I don't
know how many times people have had to respond to questions by saying,
"Read the documentation." The guys on the MFC&T team have done a lot of
work to save us time. Lets at least have the curitousy to read the help
before wasting everyone's time (I hope everyone realizes that Mike B is
not required to be active on this list. He is here because he WANTS to
be helpful.) ClassWizard & AppWizard can do a lot of work for you, but
sometimes you really should be able to work without it.
I know some of you have nothing better to do then to send flames back,
but I wish you wouldn't waste my time.
Thanks for listening..
Paul Stemper
-----Original Message-----
From: Ehab bassilli [SMTP:mfc-l@netcom.com]
Sent: Saturday, March 29, 1997 6:03 PM
To: mfc-l
Subject: CHILD MDI -
Environment: VC++ 5.0, Win 95
I need to create an MDI where the user has a number of CHILD documents
that can be created based upon their initial selection from the FILE
menu..
eg.
FILE EDIT VIEW ...
* >dialog one
* >dialog two
* >dialog etc..
I need the children (kids) to be dialog based..
I know, well, I suppose that the class for the viewtype shuld be set to :
CFormView...
OK.. then what? I need to create different forms/dialogs that should be
treated as children documents of the MDI...
Please please help
Ehab Bassilli..
ehab@total.net
------------------------- Original message header:
>MAIL FROM:
>RCPT TO:
>DATA
>Received: by extfw.mke.ra.rockwell.com; id SAA23132; Sat, 29 Mar 1997
18:04:53 -0600
>Received: from listless.netcom.com(206.217.29.105) by
extfw.mke.ra.rockwell.com via smap (3.2)
> id xma023109; Sat, 29 Mar 97 18:04:34 -0600
>Received: by majordomo.netcom.com (8.7.5/8.7.3/(NETCOM MLS v1.01)) id
LAA28908; Sat, 29 Mar 1997 11:04:39 -0800 (PST)
>Message-Id: <3.0.32.19970328125641.006ac20c@total.net>
>X-Sender: ehab@total.net
>X-Mailer: Windows Eudora Pro Version 3.0 Demo (32)
>Date: Fri, 28 Mar 1997 12:56:44 -0500
>To: mfc-l@netcom.com
>From: Ehab bassilli
>Subject: CHILD MDI -
>Mime-Version: 1.0
>Content-Type: text/plain; charset="us-ascii"
>Sender: owner-mfc-l@majordomo.netcom.com
>Errors-To: owner-mfc-l@majordomo.netcom.com
>Precedence: bulk
>Reply-To: mfc-l@netcom.com
------------------------- End of message header.
Become an MFC-L member
| Вернуться в корень Архива
|