The information in this article applies to:
SYMPTOMSThe following error message can occur after adding a message handler for a class when using the Microsoft Foundation Classes (MFC):
CAUSEThis compiler error message occurs if a window message handler macro has been added to the message map of a class that is not derived from CWnd. For example, if you declare a class as
with a message map such as the following
the C2642 error will occur. Examine the macro ON_REGISTERED_MESSAGE()
in AFXMSG_.H; you can see why the error occurs. Here is the definition
of the macro:
In MFC 4.0 (included with Visual C++ 4.0), this macro is defined as:
Notice that the function pointer is cast to a pointer to a function in
the CWnd scope. In the example above, CMyApp is derived only from CWinApp.
As it does not have CWnd as a base class, CMyApp will not receive window
messages. It only receives command messages that are sent through the
command routing process.
RESOLUTION
The following are two possible workarounds to resolve the problem:
-or- MORE INFORMATION
Message maps contain six different categories of messages:
The last two categories are standard window messages and can be handled only in a CWnd-derived class. These messages are not routed via the framework's command routing mechanism. REFERENCESFor information about other causes of the C2642 error message, please see the following article(s) in the Microsoft Knowledge Base: Q85521 C2642 in Message Map Caused by Incorrect PrototypesInformation about command routing can be found in Chapter 3 of the "Class Library Reference," MFC Technical Note 21, and Chapter 6 of the "Class Library User's Guide." Additional query words: 7.00 1.00 1.50 1.51 1.52 2.00 2.10 2.50 2.51 2.52 3.00 3.10 4.00
Keywords : kbMFC kbVC100 kbVC150 kbVC200 kbVC400 kbGrpMFCATL kbArchitecture |
Last Reviewed: November 25, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |