BrainDump
  Home arrow BrainDump arrow Page 2 - The Resource View of the MFC
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

The Resource View of the MFC
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-03-26

    Table of Contents:
  • The Resource View of the MFC
  • Menu Editing
  • Dialog Boxes
  • Toolbar, Hot-Keys and Icons
  • Epilogue

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    The Resource View of the MFC - Menu Editing
    (Page 2 of 5 )

    You can already see that Microsoft has included quite a few little tools into MFC that can enhance your programming speed dramatically. Resource manager has been included for even greater efficiency. With this handy tool we can customize our resources at a blazing fast speed. Resources can be categorized as Accelerator keys, the Dialog boxes, Icons, String Tables, Menus, Toolbars... and even a nice version of the info table.

    The menu is at the base/top of each application window. You already see them everywhere, that is if you've spent at least 10 minutes in Windows. If a user wants to customize something, most of the time, the first place s/he expects this kind of option is the menu.

    Considering this, your own application shouldn't be an exception. This way, any user can find his/her way in a familiar situation. Scaring away users by implementing something extremely unfamiliar or new isn't great. You may ask, how will we customize them? Well, the answer is quite simple; it's presented below.

    All you need to do is open up the corresponding part of the resource tree and select IDR_MFC_exampleTYPE. That part is responsible for the mainframes menu. The initial customization is quite intuitive and can be done without any additional effort; typing the new menu string where you want a new menu is very straightforward. Additionally you may also insert separators by right clicking and selecting Add separator. For our application, let's make something like this.



    At this time, the menus are useless, so we need to assign them some sort of functionality. Right click on the desired menu and select Add Event Handler...



    Select the class that you want to assign and we are ready to go. In OnDataoptionsEnterdata, we can enter all the things we should be able to do and expect from pressing on the menu(s).

    At this part, we'll learn how to add check boxes near a menu. It is quite a useful option and fits perfectly in our Use Blue Bk -> True section. To accomplish this, you need to repeat the above process once again, but this time choose the UPDATE_COMMAND_UI message type instead.

    Add a _useBlue bool type variable that will indicate whether we draw with a blue background or not and set a start value of false. Add the COMMAND message so that we can change the value of the _useBlue; therefore, when you push the True menu we can signal to the application that a change has been made.

    Each time the True menu is drawn, the OnUpdateUsebluebkTrue32775 function is called. So in it we indicate whether or not the check box has to be drawn. Add the following code in there. The result must be something like the screen shot below - a check box that disappears and appears upon selection.


    void CMFC_exampleView::OnUsebluebkTrue()

    {

    _useBlue= (!_useBlue);

    Invalidate();

    }

     

    void CMFC_exampleView::OnUpdateUsebluebkTrue32775(CCmdUI *pCmdUI)

    {

    pCmdUI->SetCheck(_useBlue);

    }



    A utility for Enter Data... will be integrated in the following page and there you are also going to find out how to create a Dialog Box. In the same way, you can implement radio boxes too.

    More BrainDump Articles
    More By Gabor Bernat


       · Welcome my friend and thanks for reading my article. As previously mentioned I...
     

    BRAINDUMP ARTICLES

    - Handling Multiple Contracts with Indigo
    - Cleaning Out Your Data in XP
    - Multiple Service Contracts and Indigo
    - Cleaning Out Your Programs in XP
    - Handling Metadata with Indigo
    - Building Blocks for a WCF Service Web Site
    - Help! I Need Some Remote Assistance
    - Using Service Templates with Indigo
    - Windows XP Tips for Task Manager
    - Generating Clients and Services with Indigo
    - Vista SP1, A Review
    - Services and the WCF
    - VBScript: Final Date Functions
    - Creating Services with the WCF
    - The Resource View of the MFC




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway