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::OnToolTipNot ify( 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.
I used:
EnableToolTips(TRUE);
...
ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify)
...
BOOL CTopologyDlg::OnToolTipNot
{
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.
ASKER
I need just one in the mouse over event.
I don't see the toolbar.
any other code is welcome :)
I don't see the toolbar.
any other code is welcome :)
ASKER
Do I have to use CToolTipCtrl ?
I see samples without the control
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::PreSubcla ssWindow()
{
..
// Create the tooltip
CRect rect;
GetClientRect(rect);
m_ToolTip.Create(this);
m_ToolTip.AddTool(this, "My Tooltip", rect, TOOLTIP_ID);
CStatic::PreSubclassWindow ();
}
BOOL CTooltipControl::PreTransl ateMessage (MSG* pMsg)
{
m_ToolTip.RelayEvent(pMsg) ;
return CStatic::PreTranslateMessa ge(pMsg);
}
Do you want the toolbar on the dialog?
Here is the way for tooltip control:
class CTooltipControl: public CStatic
{
...
CToolTipCtrl m_ToolTip;
};
void CTooltipControl::PreSubcla
{
..
// Create the tooltip
CRect rect;
GetClientRect(rect);
m_ToolTip.Create(this);
m_ToolTip.AddTool(this, "My Tooltip", rect, TOOLTIP_ID);
CStatic::PreSubclassWindow
}
BOOL CTooltipControl::PreTransl
{
m_ToolTip.RelayEvent(pMsg)
return CStatic::PreTranslateMessa
}
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
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/_sample_mfc_testhelp.asp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!! :(