0
votes

In MFC (old I know), I am trying to add a Tooltip that appears only when a radio button is disabled.

I am able to show the tooltip with code such as:

m_ToolTip.Create(this);
m_ToolTip.AddTool(GetDlgItem(IDC_RADIOBUTTON), "Tooltip text");
m_ToolTip.Activate(TRUE);

But it does not work when my radio button is disabled, (apparently that is by design)

After some research it appears that I need to override the

PreTranslateMessage()

function to get the ToolTip showing, perhaps tracking when the mouse enters into the control area, but I don't know how to do that.

Any help much appreciated.

1
Since the window is disabled, you are not going to be able to use tooltips with it. However, you can use GetWindowRect(), translate to a client area rectangle on the dialog, and then add a tool for the space that the window occupies. Look at overrides for CToolTipCtrl::AddTool that take RECT arguments. - Joseph Willcoxson

1 Answers

0
votes
BOOL MyDialog::PreTranslateMessage(MSG* pMsg)
{
    // GF: Fix tooltips on disabled items.
    m_wndCtrl.RelayEvent(pMsg->message, pMsg->wParam, pMsg->lParam);
    m_wndCtrl.UpdateWindow();
    return CDialog::PreTranslateMessage(pMsg);
}

This works for me.