Archived

This topic is now archived and is closed to further replies.

MFC question

This topic is 5041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites