MDI problem
-
Hi. Im doing a MDI program using CFormView. When I first run the program, there is a child window in the parent window. I do not want to open up the program with a child window. I want to see the child window only when I click File->Open. How do I do that? Thanks.
-
Hi. Im doing a MDI program using CFormView. When I first run the program, there is a child window in the parent window. I do not want to open up the program with a child window. I want to see the child window only when I click File->Open. How do I do that? Thanks.
Place the following code between ParseCommandLine and ProcessShellCommand function calls in your CMyApp::InitInstance method;
if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) { cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; }
-- ===== Arman
-
Hi. Im doing a MDI program using CFormView. When I first run the program, there is a child window in the parent window. I do not want to open up the program with a child window. I want to see the child window only when I click File->Open. How do I do that? Thanks.
BOOL CYourApp::InitInstance() { //... CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Added to prevent New Empty Document at startup if (cmdInfo.m_nShellCommand==CCommandLineInfo::FileNew) { cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing; } //... }
-
BOOL CYourApp::InitInstance() { //... CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Added to prevent New Empty Document at startup if (cmdInfo.m_nShellCommand==CCommandLineInfo::FileNew) { cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing; } //... }
Hey. Thanks. But now, if I clicked File->Open, it wont display the child window. Only if I clicked File->New, will the child window be displayed. How can I make the child window be displayed when I clicked File->Open? And also, after I get the child window to be displayed through File->New, when I tried to maximize the window, my GUI is not there anymore. Why is that so?
-
Hey. Thanks. But now, if I clicked File->Open, it wont display the child window. Only if I clicked File->New, will the child window be displayed. How can I make the child window be displayed when I clicked File->Open? And also, after I get the child window to be displayed through File->New, when I tried to maximize the window, my GUI is not there anymore. Why is that so?
ReturnRain wrote:
it wont display the child window
The code provided is pretty much an industry standard way in MFC to prevent the initial document in an MDI application. It appears in many articles and books. It should not have any effect on on the operations you are describing so my best guess is that you have code elsewhere that effects the actions you are having difficulty with. One way to verify this is to create a MFC MDI application using CFormView and dropping that snippet into the appropriate spot and running it without any other code added and you should see that the open and new and child maximize work correctly (at least on VC++ 6.0 and VC++ 2003). I don't use VC++ 2005 so I have no way to verify it using that IDE.