migue
asked on
SDI: One Doc many views....
I know how to setup the MFC app. to handle one doc and a view for it.But, how do I support one doc. and X number of views for it ?
Or is it more efficient to have one doc, one view for it and let the view code render the data in different ways ?
Or is it more efficient to have one doc, one view for it and let the view code render the data in different ways ?
Look at codguru
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Incidentally MDI can be used for single doc multiple views (you need to add code to prevent creation of a second doc without closing the first one). A reason to do this would be if you want tiling etc. menu options or the user to be able to size multiple views _independantly_ in both x and y dimensions
ASKER
to plaroche:
proposed solution looks good, but don't want to delete the default view, just add more views. Where do you propose to set(call SetActiveView) a particular view ? In other words, at what point of the code do I set a particular view ?
NOTE: bumped up the points.
proposed solution looks good, but don't want to delete the default view, just add more views. Where do you propose to set(call SetActiveView) a particular view ? In other words, at what point of the code do I set a particular view ?
NOTE: bumped up the points.
In my project my views are created by posting a message from my CWinApp::InitInstance to my CMainFrame. Doing that this way I am sure that my connection to the material is done and all my init code has been executed.
Having a bit more experience now I think I would have placed the view creation code in CMainFrame::OnCreate (handler of WM_CREATE).
So just save the context and from OnCreate call a function to create your other views. When they are all created and moved to their correct place do a SetActiveView on the one you wish, your choice.
The user can also change operating mode from the app and it creates another view. Doing this is then simple, just create the new view with the saved context and position it where it needs to go, making sure to resize the other views accordingly.
Having a bit more experience now I think I would have placed the view creation code in CMainFrame::OnCreate (handler of WM_CREATE).
So just save the context and from OnCreate call a function to create your other views. When they are all created and moved to their correct place do a SetActiveView on the one you wish, your choice.
The user can also change operating mode from the app and it creates another view. Doing this is then simple, just create the new view with the saved context and position it where it needs to go, making sure to resize the other views accordingly.