-
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).
-
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)?