Link to home
Start Free TrialLog in
Avatar of yonit
yonit

asked on

Add tooltip to a child window

I want to add tooltip to an ocx control placed on a dialog child window. I also have for the ocx mouse move event.
I used:

EnableToolTips(TRUE);
...
ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify)
...
BOOL CTopologyDlg::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
{    
    TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
    UINT nID =pNMHDR->idFrom;
    if (pTTT->uFlags & TTF_IDISHWND)
    {
        // idFrom is actually the HWND of the tool
        nID = ::GetDlgCtrlID((HWND)nID);
        if(nID)
        {
            pTTT->lpszText = MAKEINTRESOURCE(nID);
            pTTT->hinst = AfxGetResourceHandle();
            return(TRUE);
        }
    }
     return(TRUE);
}

What else do I need ?

Thanks.
Avatar of AlexNek
AlexNek

2 yonit
Do you need one tooltip for the Ocx item in a dialog or you need different tooltips in the Ocx item area? Which problems do you have?

PS:
nID = ::GetDlgCtrlID((HWND)nID);
Hurrah, Microsoft programming style!! :(
Avatar of yonit

ASKER

I need just one in the mouse over event.
I don't see the toolbar.
any other code is welcome :)
Avatar of yonit

ASKER

Do I have to use CToolTipCtrl ?
I see samples without the control
>I don't see the toolbar.
Do you want the toolbar on the dialog?

Here is the way for tooltip control:

class CTooltipControl: public CStatic
{
...
  CToolTipCtrl m_ToolTip;
};

void CTooltipControl::PreSubclassWindow()
{
..
     // Create the tooltip
     CRect rect;
     GetClientRect(rect);
     m_ToolTip.Create(this);
     m_ToolTip.AddTool(this, "My Tooltip", rect, TOOLTIP_ID);

     CStatic::PreSubclassWindow();
}

BOOL CTooltipControl::PreTranslateMessage(MSG* pMsg)
{
     m_ToolTip.RelayEvent(pMsg);
     return CStatic::PreTranslateMessage(pMsg);
}
Avatar of yonit

ASKER

no toolbar. just tooltip
TESTHELP: ActiveX Control with Tooltips and Help. (Sample only on CD, I have it)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/_sample_mfc_testhelp.asp
ASKER CERTIFIED SOLUTION
Avatar of AlexNek
AlexNek

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial