Newlines in tooltips

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
huge
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Feb 06, 2006 12:53 pm
Contact:

Post by huge » Fri Oct 20, 2006 6:59 am

Hi,
To awaken an old thread...
I have found the solution for this problem : TTM_SETMAXTIPWIDTH must be supplied at least once for the "\r\n" combo to work.

ie, replace the code inside #ifdef TTM_SETMAXTIPWIDTH with something like: SendMessage((HWND)GetToolTipCtrl(), TTM_SETMAXTIPWIDTH, 0, 300);

That is it. This fixes it for subsequent "SetToolTip()" calls.

You should also decide how to handle "\n" in a consistent way. ie.
1. specify "\n" and replace it with "\r\n" or space depending of comctrl version.
2. specify "\r\n" and strip them depending.
3. Have "IsMultiLineSupported" and let the user decide (in combination with 1 or 2 ?).

Currently I am using option 4. : specify "\r\n" and ignore other probelms.

Paulsen
Experienced Solver
Experienced Solver
Posts: 53
Joined: Wed May 24, 2006 1:56 pm
Location: Germany

Post by Paulsen » Tue Nov 07, 2006 2:59 pm

huge wrote: replace the code inside #ifdef TTM_SETMAXTIPWIDTH with something like: SendMessage((HWND)GetToolTipCtrl(), TTM_SETMAXTIPWIDTH, 0, 300);
I second that. Any sensible value between about 300-450 will work nicely. The code as it stands now is simply an elaborately done, over-engineered bug.

Set the tool tip size to the width of the first line, why come up with something like this? If you happen to pick the wrong font to calculate the size (which seems to happen most of the time), not even the first line will display correctly.

I will open a bug report on the source forge tracker, if no one else has done this already.
Paulsen

Post Reply