Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How does Word 2000 bring up a new window when you click File/New and still maintain a single instance?

0 views
Skip to first unread message

Chris Jordan

unread,
Jul 14, 2000, 3:00:00 AM7/14/00
to
When you click "File->New" in Word 2000, it brings up antoher window in the
same App, you can see this in the TaskManager, there is only one Instance,
it's kinda like an SDI app and an MDI app mixed together... how do they
achive this? I thought maybe i should write a new CDocTemplate??

Any thoughts??

TIA,

Chris

Aurelian Coasan [MS]

unread,
Jul 14, 2000, 3:00:00 AM7/14/00
to

Hi Chris

your question was interesting and i dealt a little bit with the issue.
there are several things which i would to point out.

the mfc document-view architecture was not designed to serve such
configurations. that's why you should forget about it.
one could say: do it in plain windows programming.
"allmighty..." would one think, "beware of this". besides of this, the whole
mfc wrappers around windows objects and some of their interaction would be
lost. missing some class wizzard capabilities and partly oo code (the latter
shortage is not a necessity but would then demand a lot of work from you)
is not to underestimate.

so there is a gentle middle way. it demands little addings but i'd rather
say it's fine. it still uses all of the mfc capabilities but the
document-view architecture. you would have to simulate the latter. you can
choose between a simple, easy implementable way ore a more elaborated and
elegant.
i'll sketch the simple way.

i will just outline one possible solution.

create an mfc sdi project but DISABLE on the first page of the wizzard the
checkbox "support for the document-view architecture".
it will be an mfc sdi project WITHOUT a visual c++ built in doc-view
arcitecture. (it will have only a view and a main frame class - but no doc
and no doc template classes)

define in the application class a membervariable of the type "list of
CMainFrame",
that is a pointer to an object of class, say
class CMyFramesList
{
CMainFrame * m_pMainFrame;
CMyFramesList* pNext;
};

add a "new" entry in your "file" menu and a handler for this entry in the
application class.
in the handler create a new object of class CMainFrame, like:
===========
CMainFrame * pAnderesFenster;
pAnderesFenster = new CMainFrame();
pAnderesFenster->LoadFrame(IDR_MAINFRAME,
WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
NULL);
// Das einzige Fenster ist initialisiert und kann jetzt angezeigt und
aktualisiert werden.
pAnderesFenster->ShowWindow(SW_SHOW);
pAnderesFenster->UpdateWindow();
===========
then add this pointer to the list mentioned above.

with this configuration you can use most of the usual capabilities (f.i.
message mapping on handlers in the view or the main frame classes)
and it will work (i tested it).

take care of the following thing:
it would be good to take care in the destructor of the main frame class of
the removal of the element in the list which points to the object beéing
destroyed. it's up to you how to manage it. what about a pointer in the main
frame class to the concerned element of the list?

now to the last thing which you maybe wouldn't like to miss:
the doc-view architecture.

the elegant but work intensive (and exposed to the rsik of bugs) way would
be to construct yourself this architecture. for instance an appropriate
"document template class" this would work by all means strongly different
than the typical mfc inbuilt one (which we didn't use here).

i'll make some notes to the simple model.
your app object allready has a list of the frames.
your view objects could have a pointer to the main frame object to which any
one is associated (take also a look to the default code that visual c++
injects in this kind of projects to understand the connection between the
view and the main frame object - f.i. the members
CMainFrame::OnCreate and m_wndView).
the view objects would also have a pointer to a document object whose class
you have to define.
the document class would have a pointer to a (list of) view object(s) - the
view(s) associated with it.

you then have to take care of the different interactions : analyse them
carefully.
add/define member functions for the view and the doc class which are
equivalents of the member functions of the CView and CDocument classes
(which don't appear in this project). (f.i. GetDocument for the view and the
member functions of the CDocument class (if you want to do it like there: to
handle serialization in that class and to support possible multiple views;
there should be an Update(All)View(s) method in your self defined document
class).
don't forget the connection between the creation of the three objects :
frame, view and doc.
one is predefined: the frame creates the view.
if you don't care about the possibility of multiple views per document then
things are pretty clear by now : one doc - one frame - one view.
the frame would also create the doc. every frame had to have a doc and every
open doc would be in a frame.
i think this is the most probable design one would use.

otherwise there would be at least two variants:
the frame could create as well the document and also associate the view with
the document. in this case multiple views associatied with the document
should rather be in a certain way "chidren" of the frame. i don't mean
necessary/only windows-children but a semantical "belonging" implemented in
a certain way.

the other possibility is that you create not a new frame in the "new"
handler, but a new document. your design would (probably) associate in this
case frames with views. anyway, at least the doc would be the main element.
so the code above would look a little bit different. the difference is clear
: docs create frames that create views.
you would have to alter also the default injected code a little bit in this
case.

hope that gives you some useful hints.

Regards
Aurelian Coasan

"Chris Jordan" <CJo...@serif.com> schrieb im Newsbeitrag
news:8kmen0$f9o$1...@soap.pipex.net...

Tim McKay

unread,
Jul 14, 2000, 3:00:00 AM7/14/00
to

Err.... Sounds to me like a "future API consideration" to me. a.k.a.
"Undocumented feature."
tm.vcf

Joseph M. Newcomer

unread,
Jul 15, 2000, 3:00:00 AM7/15/00
to
This would be by creating another overlapped window. This is an old
technique that has gone neglected for many years because it created
applications that were hard to use. It involves creating a new frame
window and maintaining a reference count of how many such you have
created; when you close each one, you decrement the reference count.
When the last one is closed and the reference count goes to zero, you
can exit the application.
joe

On Fri, 14 Jul 2000 20:19:21 -0600, Tim McKay <t...@anykey.ca> wrote:

>
>Err.... Sounds to me like a "future API consideration" to me. a.k.a.
>"Undocumented feature."
>
>
>

>> "Chris Jordan" <CJo...@serif.com> schrieb im Newsbeitrag
>> news:8kmen0$f9o$1...@soap.pipex.net...
>> > When you click "File->New" in Word 2000, it brings up antoher window in
>> the
>> > same App, you can see this in the TaskManager, there is only one Instance,
>> > it's kinda like an SDI app and an MDI app mixed together... how do they
>> > achive this? I thought maybe i should write a new CDocTemplate??
>> >
>> > Any thoughts??
>> >
>> > TIA,
>> >
>> > Chris
>> >
>> >

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm

0 new messages