October 14th, 2003, 04:59 AM
MFC Dialog: How to enhance a dialog-based application with Menu, Toolbar...?
Q: How to enhance a dialog-based application with Menu, Toolbar...?
Q: How can I handle accelerators?
Q: How can I make my window resizable?
Q: How can I add scrolling to my window?
Q: How can I add document/view support?
Q: How can I print the contents of my window?
A: The answer to all of the above is: Don't. Create an SDI or MDI application instead.
All of the features mentioned above can be added automatically by the AppWizard when you choose SDI or MDI as the application type. The code which implements them is already part of MFC. And while it is possible to add those features to a dialog-based application, it usually requires some twisting and tweaking and lastly rewriting of code that is already there.
Historically, there were only two application types proposed by the AppWizard: SDI and MDI. The type "dialog-based" was only added in VC++ 5.0, and it is meant mainly for rapid prototyping or testing purposes. Only very few real-world applications live entirely within a modal dialog. The support MFC offers for dialog-based applications is very limited, as opposed to SDI or MDI.
So when you create an application using AppWizard, think twice and triple before choosing dialog-based. Only use it if you are sure that you will never want to add any of the features mentioned above. If you need the ease to create your UI using the resource editor, choose SDI and use a CFormView as the view type. Note that implementing any single of the above features in a dialog-based app is usually more complicated and risky than creating an SDI app right away and turning off the features that you don't need.
And in the case you already did a lot of implementation work in a dialog-based application: Create a new project as SDI. Choose CFormView as the view type. Now copy the dialog resource and the implementation code from your dialog class to the form view class: Most of your code will work without major modification in the new context.
Last edited by Andreas Masur; July 24th, 2005 at 04:33 PM.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!