问题
I was trying the CMFCButton
tooltips and found that if I call EnableFullText()
the tooltips don't show.
Here's a little sample:
// In OnInitDialog()
c_MyBtn.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT;
c_MyBtn.SetMouseCursorHand();
c_MyBtn.EnableFullTextTooltip();
c_MyBtn.SetTooltip(_T("Some string"));
c_MyBtn.Invalidate();
So, does that function do something? The docs say it "Specifies whether to display the full text of a tooltip in a large tooltip window or a truncated version of the text in a small tooltip window", but the only thing I see is that tooltips don't show. I've tried long strings and strings with line breaks, but nothing.
Anyone knows the purpose of this function and how to use it?
I'm using Visual Studio 2008 SP1.
回答1:
The wonderful thing about MFC is that Microsoft gives you the source. If there's ever a question, just look at the code.
Looking at EnableFullTextTooltip
, all it does is set a couple of boolean flags. The important one is m_bDelayFullTextTooltipSet
. This flag is checked in the OnDraw
function. The tooltip text is set with SetTooltip
: if the full button text fits on the button itself, it's called with NULL, otherwise it's called with the button text.
It appears the intent of this function is to have the tooltip display the text that should have been drawn on the button itself when the button is too small. If that's not what you want, avoid this function because it will override the tooltip that you have set.
来源:https://stackoverflow.com/questions/8053302/what-does-cmfcbuttonenablefulltexttooltip-do