ID Number: Q85521
1.00 | 1.00
MS-DOS | WINDOWS
docerr
Summary:
SYMPTOMS
When using the message-map mechanism provided by the Microsoft
Foundation Class (MFC) libraries version 1.0, which shipped with
the Microsoft C/C++ compiler version 7.0, the following error may
be generated if the function declarations do not match the function
prototypes in the header file AFXWIN.H.
error C2642: cast to pointer to member must be from related
pointer to member
CAUSE
Functions that handle Windows messages may be defined as member
functions of a derived window class. The message-routing mechanism
provided by MFC through the macros DECLARE_MESSAGE_MAP and
BEGIN/END_MESSAGE_MAP requires that the functions defined in the
derived class exactly match the parameters for the functions
prototyped in AFXWIN.H.
RESOLUTION
Check the message-handler function prototypes against those in
AFXWIN.H. Make sure that the parameter types and return type are
identical.
More Information:
There are some documentation errors in the "Microsoft C/C++ Class
Libraries Reference" and in the online help for the prototypes of some
message-handler functions. These errors are documented in part 7 of
the file ERRATA2.TXT that comes with Microsoft C/C++ 7.0. The
following message-handler functions are documented incorrectly in the
"Microsoft C/C++ Class Libraries Reference:"
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);
These should be prototyped as shown in the online help, ERRATA2.TXT,
and AFXWIN.H:
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 following message-handler function is documented incorrectly in
the "Microsoft C/C++ Class Libraries Reference" and in the online
help:
afx_msg void OnNcCalcSize( LPRECT );
This function should be prototyped as shown in AFXWIN.H and
ERRATA2.TXT:
afx_msg void OnNcCalcSize( NCCALCSIZE_PARAMS FAR* );
The following message-handler functions are not in the "Microsoft
C/C++ Class Libraries Reference" but are in the online help:
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 AFXWIN.H are correct. All
discrepancies in both the online help and in the "Microsoft C/C++
Class Libraries Reference" may be resolved by checking the actual
prototypes defined in the header file.
Additional reference words: 7.00 1.00 afx