CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Afx_pmsg???!!!

  1. #1
    Join Date
    Apr 2002
    Posts
    42

    Afx_pmsg???!!!

    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?

  2. #2
    Join Date
    Aug 2002
    Location
    ireland
    Posts
    291
    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.

  3. #3
    Join Date
    Sep 2003
    Location
    Forever Gone... For Now...
    Posts
    1,515
    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.
    Thought for the day/week/month/year:
    Windows System Error 4006:
    Replication with a nonconfigured partner is not allowed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured