MFC question
How can I make OnNewDocument not be called when the window opens, but only when the user presses File->New.
I could offcourse use a varbiable that saves wether the function was called once and skips that call. But is there a more elegant solution?
-CProgrammer
I had exactly this problem, you want "no document" in an SDI app at launch.
What we did was to set a boolean flag in the app class which was set to true at the end of InitInstance, which is checked in OnNewDocument and returns straight away in that case.
Other problems arise from this approach though. Prefer an MDI app or ditch the doc/view framework altogether is my recommendation. Its too late for me now!
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
What we did was to set a boolean flag in the app class which was set to true at the end of InitInstance, which is checked in OnNewDocument and returns straight away in that case.
Other problems arise from this approach though. Prefer an MDI app or ditch the doc/view framework altogether is my recommendation. Its too late for me now!
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
I had feared the worst. Thanks for the reply, it''s good to know others are struggling on this. It is however hard to believe that microsoft didnt add a flag or something, I mean at least 50% of apps dont want a document at startup.
-CProgrammer
-CProgrammer
As alternative before the call of ProcessShellCommand in the Main App put this:
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
MFC and elegance never go in the same sentence, unless there is some sort of negatory clause in there.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement