Hi Bill,
I've never tried to do this (I.E., my programs always have a view open), but
here's my two cents. You can process information in the document and not
show it on the view until you are ready. In the view's OnUpdate() routine
you cau use hints from the document to tell the view how to handle the
information...
"Bill Brehm>" <<don't want any spam>wrote in message
Quote
In an MFC, MDI, document-view application, is it possible to close all the
views on a document and keep the document open? If so, how would I go
about
opening a new view on a document when I need to? If so, is the default
doc-view app setup by the new project wizard supposed to allow it? If not,
is there a workaround, like an invisible window?
You can close any window, but you will wantto remove (RemoveView) any views
from the document's view list when you close it just so the document object
knows it is gone. The document and view work well together, but I don't
think the document needs a view to exist. You could create a new view and
use AddView to assign it to a document just about any time or you can assign
a document to the view when a view is created. It would be more trouble to
have a view without a document since the view relies on the document for
it's data t display (in the typical model).
Quote
Is there something like a OnCloseView() that I could override to hide the
view rather than close it if it is the last one? I looked but couldn't
find
this. I could add an entry in the View menu to unhide the view.
You can use ShowWindow(SW_HIDE) on the frame window the frame or you could
simply minimize it as well.
Quote
Also, whenever I execute the application, a blank document and view are
opened by default. Is there any way to prevent this? I looked in the code
in
my project and did not find a call to OnNewDocument() or anything like
that,
so it must be buried somewhere inside MFC or the OS.
Add the folloing line to the InitInstance of the application:
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
After the CCommandLineInfo object is created:
CCommandLineInfo cmdInfo;
And before the ParseCommandLine() function is called:
ParseCommandLine(cmdInfo);
This will replace the default behavior (CCommandLineInfo::FileNew) and a new
document will not be created. This is also handy when you have more than
one document type and you don't want to display the little dialog that asks
the user what kind of document to open.
HTH,
Tom
-