Link to home
Start Free TrialLog in
Avatar of Lescha
Lescha

asked on

Modifying tooltips

How can I modify the tooltips the MFC displays in the SDI/MDI application? I want them to be dynamically-adjustable, for instance, for the tooltip which corresponds to Undo I want to show something like "Undo: 5 more available".
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

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
Avatar of bcsonka
bcsonka

Hi,

Try using the CToolTipCtrl::UpdateTipText method.  Here's an example:

================================================================================

CString tooltipMsg = "My updated tooltip text";
tooltip->UpdateTipText(tooltipMsg, cwndPtr);

================================================================================

tooltip ==> pointer to an instance of CToolTipCtrl
cwndPtr ==> pointer to the control to contain the updated tooltip text (CWnd*)

I hope that helps.
Avatar of Lescha

ASKER

Alex, could you please explain to me why there are 4 possibilities in the code? I thought Unicode would work only with one of *A or *W functions/types (which one, by the way?), and non-unicode with the other.

bcsonka, would that things could be that simple. I don't think there is a way of actually obtaining those pointers. If you know one please tell.
There are two messages: TTN_NEEDTEXTA and TTN_NEEDTEXTW. Program may be in two configurations: ANSI and Unicode. This code is written by safety way, so that it is ready to handle TTN_NEEDTEXTW in ANSI configuration. I am not sure that this can actually happen, but safety is always good.
Avatar of Lescha

ASKER

Okay... but don't I actually control whether or not my program is Unicode? Why bother with this #ifndef stuff?
This means, you always work in ANSI configuration created by VC++ by default. But you can add UNICODE configuration to your project and work in it (this is a best choice for WinNT and later). The code from this sample is OK both for UNICODE and ANSI configurations. You can read more information here:
http://www.codeproject.com/cpp/unicode.asp
 
Avatar of Lescha

ASKER

Okay, thanks.
The answer most probably will go to Alex, but I'll wait for bcsonka for a day or two.