Hi,
i've got a CDialog derived class and i want to show a multiline tooltip for a button.
There is a OnToolTipNeedText function OnToolTipNeedText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ) to catch the TTN_NEEDTEXT message, where i feed
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
pTTT->lpszText = MAKEINTRESOURCE(nID);
just like a sample in msdn help.
It seems that it's impossible to show a multiline tooltip this way . I use
in the resource string to create line breaks.
Thanks, Petra
Comments
. Hope this helps.
You are more advanced than me. I would be happy to get a tooltip in MFC at all.[/blue]
: Hi,
: i've got a CDialog derived class and i want to show a multiline tooltip for a button.
: There is a OnToolTipNeedText function OnToolTipNeedText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ) to catch the TTN_NEEDTEXT message, where i feed
: TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
: pTTT->lpszText = MAKEINTRESOURCE(nID);
: just like a sample in msdn help.
: It seems that it's impossible to show a multiline tooltip this way . I use
in the resource string to create line breaks.
: Thanks, Petra
:
. Hope this helps.
: You are more advanced than me. I would be happy to get a tooltip in MFC at all.[/blue]
: : Hi,
look around on www.codeproject.com because they have several MFC classes that do tooltips, multiline tootips, and round tooltips.
: : [blue]Try
. Hope this helps.
: : You are more advanced than me. I would be happy to get a tooltip in MFC at all.[/blue]
: : : Hi,
:
: look around on www.codeproject.com because they have several MFC classes that do tooltips, multiline tootips, and round tooltips.
:
(my answer is late, somehow the notification didn't work.)
no, that doesn't work, the
and
appears as little rectangles
in the tooltip.
: [blue]Try
. Hope this helps.
: You are more advanced than me. I would be happy to get a tooltip in MFC at all.[/blue]
Just look in the msdn documentation of CWnd EnableTooltips and the sample there.
Thank you for your answer,
Petra
: : Hi,
: : i've got a CDialog derived class and i want to show a multiline tooltip for a button.
: : There is a OnToolTipNeedText function OnToolTipNeedText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ) to catch the TTN_NEEDTEXT message, where i feed
: : TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
: : pTTT->lpszText = MAKEINTRESOURCE(nID);
: : just like a sample in msdn help.
: : It seems that it's impossible to show a multiline tooltip this way . I use
in the resource string to create line breaks.
: : Thanks, Petra
: :
:
:
:
:
: i've got a CDialog derived class and i want to show a multiline tooltip for a button.
: There is a OnToolTipNeedText function OnToolTipNeedText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ) to catch the TTN_NEEDTEXT message, where i feed
: TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
: pTTT->lpszText = MAKEINTRESOURCE(nID);
: just like a sample in msdn help.
: It seems that it's impossible to show a multiline tooltip this way . I use
in the resource string to create line breaks.
: Thanks, Petra
:
After I called CToolTipCtrl::SetMaxTipWidth(500) the control has no problems to display multiple lines. ( Call UpdateTipText("Line1
Line2
Line3") for a test.
: : i've got a CDialog derived class and i want to show a multiline tooltip for a button.
: : There is a OnToolTipNeedText function OnToolTipNeedText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ) to catch the TTN_NEEDTEXT message, where i feed
: : TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
: : pTTT->lpszText = MAKEINTRESOURCE(nID);
: : just like a sample in msdn help.
: : It seems that it's impossible to show a multiline tooltip this way . I use
in the resource string to create line breaks.
: : Thanks, Petra
: :
: After I called CToolTipCtrl::SetMaxTipWidth(500) the control has no problems to display multiple lines. ( Call UpdateTipText("Line1
Line2
Line3") for a test.
Hi Andreas,
i think you are right, i'll try it using a CToolTipCtrl.
Thanks,
Petra
1. Get the control's tooltip object by calling GetToolTips() or something.
2. Set the Max-tooltip width to 0 by calling SetMaxTipWidth(0) [CToolTipCtrl::SetMaxTipWidth(0)]
3.Then use "
" wherever you need a new line.
I have tried it and it works for me! The control that I am using is a CListCtrl
Hope this post will help someone ;-)
OK, here's an update(22/04/2010):
For a dialog control, Set the SetMaxTipWidth as follows in the TTN_NEEDTEXT notification function before setting the tooltip text:
AFX_MODULE_THREAD_STATE* pModuleThreadState =AfxGetModuleThreadState();
if(pModuleThreadState)
{
CToolTipCtrl* pToolTip = pModuleThreadState->m_pToolTip;
if(pToolTip)
pToolTip->SetMaxTipWidth(0);
}
That should do the trick!
Note:
1.Doing the above procedure in the init function has no affect.
2. Works if this is done just once, there is no need to set it each time when a TTN_NEEDTEXT message is handled.