Add a dynamic prompt to the button in the dialog box
Adding tooltip to the button is simple:
- 1. Add a ctooltipctrl variable to the button.
Class ctooltipbutton: Public cbutton
{
...
Protected:
Ctooltipctrl m_ctrltip;
...
}
Bool ctooltipbutton: inittooltip (INT nstringid)
{
Enabletooltips ();
M_ctrltip.create (this, tts_alwaystip );
M_ctrltip.setmaxtipwidth (10000 );
M_ctrltip.addtool (this, nstringid );
M_ctrltip.activate (true );
Return true;
}
Bool ctooltipbutton: pretranslatemessage (MSG * PMSG)
{
M_ctrltip.relayevent (PMSG );
Return cbutton: pretranslatemessage (PMSG );
}
Implementing a dynamic tooltip is also simple
Use parameters when calling addtoolLpstr_textcallbackAnd parent response in tooltipTtn_needtext(That is, ttn_getdispinfo) Notify y message..
However, how do I provide dynamic prompts for buttons in the dialog box?
Simply combine the methods described in the above two articles. However, it cannot be found that, because as the parent of the tooltip, the corresponding wm_notify message should be included in the button. However, the button cannot receive the wm_notify message, even if it is the owner window of the tooltip.
What should I do? At this time, my solution is to move the ctooltipctrl from the button to the dialog so that the dialog becomes the parent of the tooltip, and it can get the wm_notify message.
Tooltip with more than 80 characters
Tooltip with more than 80 characters must also be usedLpstr_textcallbackIn the same way, the message wm_notify is returned. At this time, the button cannot be used as the parent of the tooltip.