BrainDump
  Home arrow BrainDump arrow Page 2 - The Resource View of the MFC
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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 / 3
    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
     
     
    ADVERTISEMENT


    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

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT