BrainDump
  Home arrow BrainDump arrow Page 4 - AppWizard and More in 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

AppWizard and More in MFC
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-03-05

    Table of Contents:
  • AppWizard and More in MFC
  • Database support, user interface, and advanced features
  • Messages and the Properties Window
  • Messages and the Properties Window continued

  • 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


    AppWizard and More in MFC - Messages and the Properties Window continued


    (Page 4 of 4 )

    Overriding the messages is an easy task -- nothing devilish. Just select the corresponding class from the Class View Tab, right click on it, and select the Properties. A new window will appear in which you can find the messages tab. It is located near the lightning-like icon. If you still have trouble finding it, glance over at the image below.



    The image shows that the list will be populated by all the receivable messages in our class. In our case, that is the CMFC_exampleView class, so it has many messages in the list. Now if we want to complete a specific command at the pushdown of the left button in the client area, for example, we seek the WM_LBUTTONDOWN message and choose to override it. MFC will then complete several codes.

    First it declares the message map in the header file:


    DECLARE_MESSAGE_MAP()

    public:

    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);


    Following the implementation of the message map, observe the presence of the ON_WM_LBUTTONDOWN() message.


    BEGIN_MESSAGE_MAP(CMFC_exampleView, CView)

    // Standard printing commands

    ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)

    ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)

    ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)

    ON_WM_LBUTTONDOWN()

    END_MESSAGE_MAP()


    The saga is completed by adding the function at the end of the implementation file and taking you (the cursors) there, so you can continue with coding the commands that you are going to need.


    // CMFC_exampleView message handlers


    void CMFC_exampleView::OnLButtonDown(UINT nFlags, CPoint point)

    {

    //TODO: Add your message handler code here and/or call default


    CView::OnLButtonDown(nFlags, point);

    }


    After the TODO line, you may add all what you want after the pushdown of the left mouse button.

    That’s all, in short. These few steps can be taken individually, if you know the corresponding message name and the fact that each function is preceded by the “On” prefix added for its message. If you want to follow this path, you can use the MSDN help files, because there you will find tons of information about each message and all of their possible implementation(s).

    Now you can use the power of copy and paste to speed up this process. But why the heck should you write this in when, with a few clicks, you’ll get the same result? Also, near the message list in the Properties Window, you will find the possible events and overrides under the other tab.

    Conclusions

    Throughout this article, we demystified every aspect of AppWizard. We also learned how to respond to any message that we get from Windows. With this knowledge in your “pocket,” we can finally proceed to pure MFC coding.

    The next article is dedicated to MFC syntax accompanied by the GDI related classes and commands. We'll start with a brief description of the Device Contexts. Text writing to the client area near the CPen and CBrush class will be presented and demonstrated as well.

    The true adventure is only starting at this point; the MFC’s power will reveal itself to you. Until now, we have learned how it works, but have only seen minimal results. Not anymore, because the next article will be full of results, mostly visible ones, so you don’t want to miss it. Trust me on this.

    As usual, have a fantastic day and stay tuned because the next article is coming up soon. It is going to be published here on DevArticles too. However, in the meantime, if there are any further questions or unresolved issues related to this article or IT in general, visit the friendly ever-growing community at the DevHardware Forums.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · The first step in order to learn anything about something is to create it. Just as...
     

    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 2 Hosted by Hostway
    Stay green...Green IT