multiple docs and multiple views together
Serge Lalonde -- serge@infolytica.qc.ca
Friday, July 12, 1996
Hi there!
Environment: Win NT 3.51, VC++ 4.1, MFC 4.0
Summary:
--------
How can I have multiple documents in an MDI app use the same
4 views? It seems to me (after looking at multview and multdocs)
that each document type should have its own view. Or am I
missing something?
Explanation:
------------
Without being too long winded, here goes.
I am creating an MFC app that can open a single type of file. However
that file can contain up to 13 different types of data. My approach is
to create 13 document types to handle the different configurations (I
have to create the document myself, but I'm sure that there's a way to
to that). Each document can have the same 4 different views.
I tried to fool MFC by registering a dummy doc template so that the
file type is in the File->Open dialog, but not in the File->New dialog.
All the other doc templates appear in the File->New but not in the
File->Open. I did this by fiddling with the string resource entries.
I also used the class wizard to create my document classes and added them
in the apps InitInstance() method.
That all works fine, but when I try to create one of my "documents"
using File->New, I get a message box telling me that it failed. I think
its because I'm specifying the same view class, because that's the
only difference I can see with the samples.
Is there another approach that would be easier?
Thanks in advance.
--
Have a tremendous day!
_/_/_/_/ _/_/_/_/ _/_/_/ _/_/_/ _/_/_/_// 300 Leo Parizeau, Suite 2222
_/ _/ _/ _/ _/ _/ / Montreal, PQ, Canada H2W 2P4
_/_/_/_/ _/_/_/ _/_/_/_/ _/ _/_/ _/_/_/ / Voice: (514) 849-8752 x236
_/ _/ _/ _/ _/ _/ _/ /__Fax: (514) 849-4239__
_/_/_/_/ _/_/_/_/ _/ _/ _/_/_/ _/_/_/_/ Lalonde, Infolytica Corp.
Ash Williams -- ash@digitalworkshop.co.uk
Wednesday, July 17, 1996
[Mini-digest: 2 responses]
I'm assuming here that you're writing an app that takes one file,
alters it and writes that file back. If so you might want to consider
having just a single document class (yes class, definitely not object)
with 13 different view classes. Then have virtualy no functionality in
the document class, putting it instead in the view classes.
Thus the document class contains only the raw data, and each view class
is familiar with only one of the 13 aspects of the document, perhaps
being a friend of the document class too.
Hope this is of some help.
Ash
-----From: "Mike Blaszczak"
From: owner-mfc-l@netcom.com on behalf of Serge Lalonde
> Environment: Win NT 3.51, VC++ 4.1, MFC 4.0
That's risky: if you're using VC++ 4.1, you should use MFC 4.1, not MFC 4.0.
I don't think anyone at Microsoft has ever tested MFC 4.0 with the 4.1
compiler and runtime libraries.
> How can I have multiple documents in an MDI app use the same
> 4 views? It seems to me (after looking at multview and multdocs)
> that each document type should have its own view. Or am I
> missing something?
You're missing something: you can associate a document type with a view type
using document template--registered at your applicaitons startup in the form
of a CMultiDocTemplate instance. There's nothing to stop you from associating
two different document classes with the same view class.
> I am creating an MFC app that can open a single type of file. However
> that file can contain up to 13 different types of data. My approach is
> to create 13 document types to handle the different configurations (I
> have to create the document myself, but I'm sure that there's a way to
> to that). Each document can have the same 4 different views.
I think this is a questionable approach. I think you should only have one
document type. That document type should be able to handle all the data types
in the given file. Juggling multiple documents all associated with the same
file at the same time isn't going to be fun or easy or elegant.
.B ekiM
These are my own words; I don't speak for Microsoft.
http://www.nwlink.com/~mikeblas
| Вернуться в корень Архива
|