Handle any category of messages using Class Wizard

WEBINAR: On-demand webcast

How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >

Very often the Class Wizard will not list the messages you want to handle. In such situations you have to add the message map entry yourself. One common situation where this happens is when you derive from a class which itself has been derived from an MFC class. For example, if CListViewEx is derived from CListView and then you derive CMyListView from CListViewEx, then you would be unable to handle any of the list view control messages in the CMyListView class using the Class Wizard.

Here's what you can do to continue using the Class Wizard. At the top of your implementation file (cpp file) will the the message map which begins with a line like

Class Wizard uses the second argument in this macro to decide whether it needs to display more messages. Since class wizard doesn't recognize the CListViewEx class it does not show any of the list view control messages. What you can do is change the line to
#define CListView CListViewEx
#undef CListView

This will now allow you to add message handlers for the CListView class.

Thanks to Gert Rijs from Netherlands for suggesting the use of the #define directive. It fools the Class Wizard parser but provides the right code to the compiler.


  • using mpeg4 in VC++

    Posted by Legacy on 03/16/2002 12:00am

    Originally posted by: tarun


    i would like to know how i could use VC++ to decode an mpeg4 input. if any body knows it please mail me at tar4ever@tatanova.com

  • What about VS.NET?

    Posted by Legacy on 02/27/2002 12:00am

    Originally posted by: Anatoly

    Nice and helpful tip. Thanks a lot. Now I'm porting existing code to VC++.Net and noticed that the same approach doesn't work anymore. At least I couldn't map CPropertyPageEx derived calss messages using IDE's standard means (Control events).

    Any ideas how to solve the problem?

    Anatoly Smelkov

  • Plz Help me

    Posted by Legacy on 01/16/2002 12:00am

    Originally posted by: Saheer

    i have a very complicated task..
    i want to create thumb nail preview of html documents
    in dialog based mfc application in vc
    if u have any idea abt this subject plz mail me
    at the following address

    regards & thanks

  • You Must Read It..!!

    Posted by Legacy on 12/13/2001 12:00am

    Originally posted by: Renjith Pandalam

    Sems to so better which help to keep some good manners and easiness whle programming with VC++.and i felt is so cool and comfortable.keep it up and good code

  • WRong in VC++

    Posted by Legacy on 04/01/2001 12:00am

    Originally posted by: AHAM

    When I started Vc++ 6.0 
    Message to me :
    Msdev has caused an error in MFC42.DLL.

    What's Wrong
    Please I want The Help

  • HAI

    Posted by Legacy on 09/29/1999 12:00am

    Originally posted by: I.R.L.REDDY






  • Thanks

    Posted by Legacy on 09/09/1999 12:00am

    Originally posted by: Alexander

    It's very usefull and buetefull!
    Thank you.

  • Be very careful

    Posted by Legacy on 07/12/1999 12:00am

    Originally posted by: Rod Ball

    Although this trick will fool it into letting you add handlers (which is awesome by the way), if you have overridden any of the handlers in your base class, they will not be called as a result but, if you are careful you will catch it. For example, if in your base class you have overridden OnSetActive so you have CBaseClass::OnSetActive and then you define the macro

    #define CPropertyPage CBaseClass
    BEGIN_MESSAGE_MAP(CDerivedClass, CPropertyPage)
    #undef CPropertyPage

    and then you use class wizard to overrided it in the derived class you will get:

    BOOL CDerivedClass::OnSetActive()
    return CPropertyPage::OnSetActive();

    and your call to the overridden OnSetActive() is completely lost because it calls the CPropertyPage's OnSetActive(). So, be careful and make sure you correct these or else you may get undesired results.

  • Document, document, document

    Posted by Legacy on 07/05/1999 12:00am

    Originally posted by: John Killingbeck

    Nice idea to solve a problem. A more thorough way to fool the system is to copy, then comment out, the original line and comment the reason for the change. That way the original can be easily restored if an upgrade bombs the trick. You want to fool the system, not your co-workers or yourself.

  • bug from MS

    Posted by Legacy on 06/17/1999 12:00am

    Originally posted by: chandra s s

    i came across this problem,but i solved in the same way.but i saw this site today only.s/w giant microsoft is
    having lot of bugs,because they are releasing products very quicly
    nice idea indeed,to fool the products.

  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • MongoDB has the flexibility, adaptability and extensibility to embrace widely varying data types and rapid design/deployment cycles. Combining MongoDB with our 5100 ECO Enterprise SSD brings amazing results in smaller, simpler deployments compared to legacy storage. In this technical brief, we compare two MongoDB test clusters, each using the Linux Logical Volume Manager (LVM) for RAID configuration: 5100 ECO 3-node cluster: Two Micron 5100 ECO (1.92TB) per node configured as a software RAID 0 (LVM) Legacy …

  • Whether a mandate to secure all web and mobile apps comes from a newly enlightened CIO or in response to a major security breach, beginning even a small application security program can be a daunting task. How will you know how many digital assets you have, let alone their risk profile? In this webinar we explore how, using a cloud solution like Fortify on Demand, even the largest organizations can begin to scan apps immediately and rapidly scale an application security program. Identify and risk rank assets, …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date