Tooltip for disabled controls (2)
The MFC code to look at is in the function RelayToolTipMessage in the file TOOLTIP.CPP.
This method has the advantage that it uses the tooltip itself to find the child window, the relevant CToolTipCtrl function is CToolTipCtrl::OnWindowFromPoint() - which has other fixes for special cases as well as the disabled control case.
Example: if using the DeveloperStudio Tooltip component, change the
block it adds in PreTranslateMessage from:
// CG: The following block was added by the ToolTips component.
{
// Let the ToolTip process this message.
m_tooltip.RelayEvent(pMsg);
}
to:
// CG: The following block was added by the ToolTips component.
{
// transate the message based on TTM_WINDOWFROMPOINT
MSG msg = *pMsg;
msg.hwnd = (HWND)m_tooltip.SendMessage(TTM_WINDOWFROMPOINT, 0, (LPARAM)&msg.pt);
CPoint pt = pMsg->pt;
if (msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST)
::ScreenToClient(msg.hwnd, &pt);
msg.lParam = MAKELONG(pt.x, pt.y);
// Let the ToolTip process this message.
m_tooltip.RelayEvent(&msg);
}
Last updated: 22 June 1998

Comments
tooltips in disabled buttons
Posted by Legacy on 01/27/2004 12:00amOriginally posted by: Jos� Miguel Gomes
I'm using a custom class of flat buttons that inherits from CButton and I wanted those buttons to show tooltips when disabled. Where do I put the code you wrote?
ReplyFix: disabled buttons show tips but respond to clicks
Posted by Legacy on 02/22/1999 12:00amOriginally posted by: Mike Harnad
Reply