Thread: MFC Message Map Problem

  1. #1
    Bioport Productions
    Join Date
    Oct 2005
    Posts
    215

    MFC Message Map Problem

    For some reason, the compiler is giving me an error when I try to use a custom message. Here's the problem:

    Code:
    error C2440: 'static_cast' : cannot convert from 'void (__thiscall CStageZeroNetworkAnalysisView::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
    And how I implemented it:
    Code:
    //////// View.h
    afx_msg void OnNewPacket(WPARAM wParam, LPARAM lParam);
    DECLARE_MESSAGE_MAP()
    
    
    //////// View.cpp
    BEGIN_MESSAGE_MAP(CStageZeroNetworkAnalysisView, CView)
    
    	ON_MESSAGE(MSG_NEW_PACKET, OnNewPacket)
    END_MESSAGE_MAP()
    
    
    ///////// The function
    void CStageZeroNetworkAnalysisView::OnNewPacket(WPARAM wParam, LPARAM lParam)
    {
    	ZeroPacket* ZP = new ZeroPacket();
    	ZP->SetData((pcap_pkthdr*)wParam, (u_char*)lParam);
    	ZP->Serialize(ZData);
    }
    Any help will be much appreciated. Thanks.
    -"What we wish, we readily believe, and what we ourselves think, we imagine others think also."
    PHP Code:
    sadf 

  2. #2
    Registered User
    Join Date
    Nov 2005
    Posts
    3

    RE: MFC Message Map Problem

    Hi,
    the function must return value LRESULT:

    afx_msg LRESULT OnNewPacket(WPARAM wParam, LPARAM lParam);

    and the similar changes in cpp file.

    PePi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with static STL i.e. map
    By vijay_choudhari in forum C++ Programming
    Replies: 2
    Last Post: 10-26-2007, 05:56 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. Problems with view's message map in MFC
    By ubermensch in forum Windows Programming
    Replies: 1
    Last Post: 05-27-2006, 06:21 PM
  4. Message printing problem
    By robert_sun in forum C Programming
    Replies: 1
    Last Post: 05-18-2004, 05:05 AM
  5. ListView ImageList problem (MFC)
    By The Dog in forum Windows Programming
    Replies: 1
    Last Post: 09-12-2002, 12:08 PM