Jump to content
  • Advertisement
Sign in to follow this  

MFC application and SDI layout [solved]

This topic is 3553 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

I've moved my level editor from a Dialog project to a SDI project in order to learn how to deal with SDI/MDI as well. However I now remember why I didn't want to learn those things in the first place. Here is my problem: From what I know, when a new file gets loaded or another one opened, the CDocument is created from somewhere within the CDocTemplate, but before the CFormView (or whatever view I choose). And that's a big problem for me. I need CFormView to be created before the document is loaded. I'm initializing a game engine that is in need of the CWnd to draw on (wich will be an item on the form). Therefore I'm creating my engine just once on the CFormView::OnInitialUpdate function (I can skip every further call, cause the CFormView is never destroyed in an SDI application, just like the CDocument). Loading my document has to happen after that, to ensure that the directx device is valid. I could easily just call the loading function from within CFormView::OnInitialUpdate, however I cannot signal a failure to the framework. Is there a way to achieve what I want? *edit* I solved the problem. Was not easy, but it is possible. I realized I had to overwrite the CSingleDocTemplate::OpenDocumentFile function to call OnInitialUpdate before calling CDocument::OnOpenDocument/OnNewDocument. The source code can be found in "C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc\docsingl.cpp". I've just copied the code from the funtion into my derrived CSingleDocTemplateEx class and moved the InitialUpdateFrame call in front of the CDocument::On*Document block. That solved my problem :) [Edited by - SiS-Shadowman on October 25, 2008 6:49:17 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!