Click to See Complete Forum and Search --> : Afx_pmsg???!!!


Robert F. Brower
June 2nd, 2002, 07:19 PM
I'm declaring:

afx_msg LRESULT OnSetModifiedFlag(WPARAM wParam, LPARAM lParam);

and putting this next line into my message map:

ON_COMMAND(SET_MODIFIED_FLAG, OnSetModifiedFlag)

and I am getting this compile error. This used to compile before I switched to VC++ .NET. =(

error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CMyCtrl::* )(WPARAM,LPARAM)' to 'AFX_PMSG'

Any ideas?

ireland
October 17th, 2003, 09:25 AM
I have the same problem. Did you find a solution?
file.h
afx_msg int OnFileSaveAs();

file.c
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
int App::OnFileSaveAs()

I get the same error, but it compiles fine with 6.0.

vicodin451
October 17th, 2003, 10:55 AM
The definition of ON_COMMAND (and other macros) changed between 6.0 and 7.0, from using explicit casting to static_cast. ON_COMMAND takes a AfxSig_vpv function [ void (void*) ], not a AfxSig_lwl [ LRESULT (WPARAM, LPARAM) ].
Change the return type and remove the WPARAM and LPARAM from the declaration and definition of your function.