CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2008
    Posts
    29

    OnNotify Not Called

    I'm sending a WM_NOTIFY message to another class, which has a message map set up to handle the notification. However, the function I've set up in the message map is never called. The code is below:

    TooltipBase.h

    Code:
        //! @brief Information shown in a tooltip
        struct TooltipData 
        {
            CString strHeader;
            CString strContents;
            CString strFooter;
        };
    
        //! @brief ON_NOTIFY structure
        struct TooltipNotification 
        {
            NMHDR hdr;
    	TooltipData* pTooltipData;
        };
    TooltipBase.cpp

    Code:
        // Code to send the message.
        TooltipNotification ttn; 
        ttn.hdr.hwndFrom = m_hParentHWnd;
        ttn.hdr.idFrom   = GetDlgCtrlID();
        ttn.hdr.code     = UDM_NEED_TOOLTIP_TEXT;
        ttn.pTooltipData = &m_TooltipData;    
        ::SendMessage( m_hParentHWnd, WM_NOTIFY, ( WPARAM ) m_hParentHWnd, ( LPARAM ) &ttn );
    Canvas2.cpp - Just a CWnd class that shapes are drawn on.

    Code:
        ON_NOTIFY           ( UDM_NEED_TOOLTIP_TEXT, NULL, OnNeedTooltipText )
    
        ....
    
        void Canvas2::OnNeedTooltipText( NMHDR* pNotifyStruct, LRESULT * result )
        {
            TRACE( _T( "The tooltip needs some text." ) );
        }
    The message appears to be sent ok, as the program continues, but I can't be sure what is happening to the message (nor if I'm right that it is being sent).

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: OnNotify Not Called

    I never sent WM_NOTIFY myself, therefore can only guess:
    why ddo you use different values of *control ID* (WPARAM) in the SendMessage call (where it is m_hParentHWnd) and in the message handler (where it is NULL)?
    Victor Nijegorodov

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