DOC: C2642 in Message Map Caused by Incorrect PrototypesID: Q85521
|
An attempt to use the message-map mechanism provided by the Microsoft Foundation Classes fails and the compiler generates the following message:
error C2642: cast to pointer to member must be from related pointer to member
The function declarations in the message map do not match the function prototypes declared in the AFXWIN.H file.
Compare the message-handler function prototypes in your application to those in the AFXWIN.H file. Verify that the parameter types and return types match.
Functions that process Windows messages can be defined as member
functions of a derived window class. To use the message-routing
mechanism the Microsoft Foundation Classes provided by the
DECLARE_MESSAGE_MAP, BEGIN_MESSAGE_MAP, and END_MESSAGE_MAP functions,
the function declarations in the derived class must exactly match the
function parameters specified in AFXWIN.H.
The "Microsoft C/C++ Class Libraries Reference" manual and online help
files provided with Microsoft C/C++ version 7.0 and with Microsoft
Visual C++ version 1.0 incorrectly document the prototypes for the
following message-handler functions, as follows:
afx_msg void OnHScroll(UINT, UINT, CWnd *);
afx_msg void OnVScroll(UINT, UINT, CWnd *);
afx_msg int OnCharToItem(UINT, CWnd *, UINT);
afx_msg int OnVKeyToItem(UINT, CWnd *, UINT);
The AFXWIN.H file and the ERRATA2.TXT file provided with C/C++ version
7.0 list the corrected function prototypes as follows:
afx_msg void OnHScroll(UINT, UINT, CScrollBar *);
afx_msg void OnVScroll(UINT, UINT, CScrollBar *);
afx_msg int OnCharToItem(UINT, CListBox *, UINT);
afx_msg int OnVKeyToItem(UINT, CListBox *, UINT);
The "Class Libraries Reference" manual for C/C++ version 7.0 and the
online help for C/C++ version 7.0 and Visual C++ version 1.0
incorrectly document the prototype for the following message-handler
function:
afx_msg void OnNcCalcSize(LPRECT);
The AFXWIN.H and ERRATA2.TXT files list the corrected function
prototype as follows:
afx_msg void OnNcCalcSize(NCCALCSIZE_PARAMS FAR *);
The online help for Visual C++ version 1.5 and Visual C++ 32-bit Edition
has the correct information.
afx_msg void OnWindowPosChanging(WINDOWPOS FAR *);
afx_msg void OnWindowPosChanged(WINDOWPOS FAR *);
afx_msg void OnDropFiles(HANDLE);
afx_msg void OnPaletteIsChanging(CWnd *);
The message-handler function prototypes in the AFXWIN.H file are
correct.
Additional query words: 7.00 1.00 2.00 2.10 afx
Keywords : kb16bitonly
Version :
Platform :
Issue type :
Last Reviewed: July 21, 1999