in an MDI application, I can suppress automatic creation a new child window
like this:
//Insert this statement in your application:
if (CCommandLineInfo::FileNew == cmdInfo.m_nShellCommand)
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
can I do anything similar in SDI
WBR, Vlad.
The short answer is No!. Please consider the following:
You can certainly supress the call to OnFileNew in the SDI startup -- just set
the value of the m_nShellCommand variable in the CCommandLineInfo struct to -1;
But if you do, you quickly find that OnFileNew does just a bit more than what
the name implies - i.e. it also creates the FrameWnd if one does not already
exist. Note that CWinApp::OnFileNew just calls the DocManager OnFileNew method,
which will eventually call CSingleDocTemplate::OpenDocumentFile with path=NULL
(i.e. open an empty document) OpenDocumentFile will create an empty CDocument
object (i.e. Serialize will not be called) and will then check to see that
pFrame is null, and if so, will create the CFrameWnd obj. So if you do not go
through the OnFileNew sequence, you don't get a frame window - and if the
creation of the frame window fails, you essentially have no application (i.e. no
main window, ergo the CWinThread::Run method has no window to receive messages).
Without a bit more information on what you are trying to accomplish, it is hard
to provide suggestion. but you may want to consider using the
CWinAPP::OnFileOpen for both the file open and the file new case. Just replace
the method in the message map macro. Something like this will cause the
FileOpen path to be taken on application startup (i.e. the user sees a File Open
dialog immediately):
BEGIN_MESSAGE_MAP(CNoNewFileApp, CWinApp)
...
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileOpen)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
I hope this helps,
best regards
roy fine
"Pan" <pan...@mailru.com> wrote in message news:uXCylH$TCHA.2624@tkmsftngp11...
> subj...
> Can I suppress the call of automatic creation of New file(document) when
> startup an application, using SDI model.
> I'd like see only frame without View. Then I want to choose and open a
> specific file.
>
> in an MDI application, I can suppress automatic creation a new child window
> like this:
>
> file://Insert this statement in your application:
sure I know that CWinApp::OnFileNew does in actual fact in SDI model.
But I hoped may be, there are something tricks or other ))
I propose to work with documents only through forms and
now I do so: (may be later I'll devise something else)
inherit my View class from CFormView
clear Form Dialog, i.e. at first I have just blank form
and suppress Untitled name in caption of my application:
CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
cs.style &= ~FWS_ADDTOTITLE; // no title
SetTitle("My application"); //Set my title
return CFrameWnd::PreCreateWindow(cs);
so for an user we have SDI application without new file ))
WBR, Vlad.
sounds as if you need to consider the MFC MDI approach. You can do exactly
what you want to do there. The application main frame window is not tied to
the CView derived object.
best regards
roy fine
"Pan" <pan...@mailru.com> wrote in message
news:elKT8ClUCHA.2704@tkmsftngp13...
WBR, Vlad.