MFC Dialog: How to enhance a dialog-based application with Menu, Toolbar...?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: MFC Dialog: How to enhance a dialog-based application with Menu, Toolbar...?

Threaded View

  1. #1
    Join Date
    Sep 2002
    Location
    14 39'19.65"N / 121 1'44.34"E
    Posts
    9,815

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center