Prev: How to - SDI
Next: SDI MAX/MIN childframe?
From: AncientSamurai on 18 Jan 2010 18:37 I got this error a few days ago and after much searching and still stuck on the problem. Any help given will be greatly appreciated. Error 1 error C2440: 'static_cast' : cannot convert from 'void (__thiscall CPage1::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' The error occurred in this code: BEGIN_MESSAGE_MAP(CPage1, CPropertyPage) //{{AFX_MSG_MAP(CPage1) ON_WM_DESTROY() ON_WM_TIMER() ON_BN_CLICKED(IDC_BUTTON_PROV_ADD, OnButtonProvAdd) ON_BN_CLICKED(IDC_BUTTON_PROV_EDIT, OnButtonProvEdit) ON_BN_CLICKED(IDC_BUTTON_PROV_DEL, OnButtonProvDel) ON_BN_CLICKED(IDC_BUTTON_TEL_ADD, OnButtonTelAdd) ON_BN_CLICKED(IDC_BUTTON_TEL_EDIT, OnButtonTelEdit) ON_BN_CLICKED(IDC_BUTTON_TEL_DEL, OnButtonTelDel) ON_BN_CLICKED(IDC_DIAL, OnDial) ON_CBN_SELCHANGE(IDC_COMBO_PROVIDER, OnSelchangeComboProvider) ON_NOTIFY(NM_CLICK, IDC_LIST_PHONES, OnClickListPhones) ON_MESSAGE(WM_DIAL_NEXT_PHONE, OnDialNextPhone) ON_MESSAGE(WM_DIAL_FUNC, OnDialFunc) //}}AFX_MSG_MAP END_MESSAGE_MAP() It occurred specifically on this line: ON_MESSAGE(WM_DIAL_NEXT_PHONE, OnDialNextPhone) Again thanks for any help given!
From: DanB on 18 Jan 2010 19:14 AncientSamurai wrote: > I got this error a few days ago and after much searching and still stuck on > the problem. Any help given will be greatly appreciated. > > Error 1 error C2440: 'static_cast' : cannot convert from 'void (__thiscall > CPage1::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' > > > The error occurred in this code: > > BEGIN_MESSAGE_MAP(CPage1, CPropertyPage) > //{{AFX_MSG_MAP(CPage1) > ON_WM_DESTROY() > ON_WM_TIMER() > ON_BN_CLICKED(IDC_BUTTON_PROV_ADD, OnButtonProvAdd) > ON_BN_CLICKED(IDC_BUTTON_PROV_EDIT, OnButtonProvEdit) > ON_BN_CLICKED(IDC_BUTTON_PROV_DEL, OnButtonProvDel) > ON_BN_CLICKED(IDC_BUTTON_TEL_ADD, OnButtonTelAdd) > ON_BN_CLICKED(IDC_BUTTON_TEL_EDIT, OnButtonTelEdit) > ON_BN_CLICKED(IDC_BUTTON_TEL_DEL, OnButtonTelDel) > ON_BN_CLICKED(IDC_DIAL, OnDial) > ON_CBN_SELCHANGE(IDC_COMBO_PROVIDER, OnSelchangeComboProvider) > ON_NOTIFY(NM_CLICK, IDC_LIST_PHONES, OnClickListPhones) > ON_MESSAGE(WM_DIAL_NEXT_PHONE, OnDialNextPhone) > ON_MESSAGE(WM_DIAL_FUNC, OnDialFunc) > //}}AFX_MSG_MAP > END_MESSAGE_MAP() > > > It occurred specifically on this line: > > ON_MESSAGE(WM_DIAL_NEXT_PHONE, OnDialNextPhone) > > Again thanks for any help given! > Your OnClickListPhones prototype is same as for commands. afx_msg void OnClickListPhones( ); Where it should be: afx_msg LRESULT OnClickListPhones( WPARAM, LPARAM ); Look at the error message again and see that it is telling you that. Best, Dan.
From: Joseph M. Newcomer on 18 Jan 2010 21:02 See below... On Mon, 18 Jan 2010 15:37:01 -0800, AncientSamurai <AncientSamurai(a)discussions.microsoft.com> wrote: >I got this error a few days ago and after much searching and still stuck on >the problem. Any help given will be greatly appreciated. > >Error 1 error C2440: 'static_cast' : cannot convert from 'void (__thiscall >CPage1::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' > > >The error occurred in this code: > >BEGIN_MESSAGE_MAP(CPage1, CPropertyPage) > //{{AFX_MSG_MAP(CPage1) > ON_WM_DESTROY() > ON_WM_TIMER() > ON_BN_CLICKED(IDC_BUTTON_PROV_ADD, OnButtonProvAdd) > ON_BN_CLICKED(IDC_BUTTON_PROV_EDIT, OnButtonProvEdit) > ON_BN_CLICKED(IDC_BUTTON_PROV_DEL, OnButtonProvDel) > ON_BN_CLICKED(IDC_BUTTON_TEL_ADD, OnButtonTelAdd) > ON_BN_CLICKED(IDC_BUTTON_TEL_EDIT, OnButtonTelEdit) > ON_BN_CLICKED(IDC_BUTTON_TEL_DEL, OnButtonTelDel) > ON_BN_CLICKED(IDC_DIAL, OnDial) > ON_CBN_SELCHANGE(IDC_COMBO_PROVIDER, OnSelchangeComboProvider) > ON_NOTIFY(NM_CLICK, IDC_LIST_PHONES, OnClickListPhones) > ON_MESSAGE(WM_DIAL_NEXT_PHONE, OnDialNextPhone) > ON_MESSAGE(WM_DIAL_FUNC, OnDialFunc) **** First note: NEVER use "WM_" to define a user-defined message! This prefix is limited to Microsoft. I've seen people spend HOURS looking for WM_ messages that were application-defined. Instead, use a prefix of your own devising which does not conflict with existing Microsoft prefixes. Note that Microsoft documentation, in their typical slovenly fashion, hints that this would make sense. They are wrong. ***** > //}}AFX_MSG_MAP >END_MESSAGE_MAP() > > >It occurred specifically on this line: > >ON_MESSAGE(WM_DIAL_NEXT_PHONE, OnDialNextPhone) **** And what is the prototype for OnDialNextPhone? Note that there is exactly ONE permitted prototype, LRESULT function_name(WPARAM, LPARAM); if you did ANYTHING ELSE you are wrong. For reasons that are not at all clear, you apparently created a function whose prototype was void function_name() which would make no sense for an ON_MESSAGE handler, which is extremely explicit about what it is supposed to call. At no point does it ever suggest that any other function prototype is permitted. Therefore, your choice of something other than the documented interface produces an error message. joe **** > >Again thanks for any help given! > > > > Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
|
Pages: 1 Prev: How to - SDI Next: SDI MAX/MIN childframe? |