Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to wordwrap text in tooltip

Tags:

c#

winforms

How to wordwrap text that need to be appear in ToolTip

like image 486
Avram Avatar asked Jul 12 '10 13:07

Avram


2 Answers

Another way, is to create a regexp that wraps automatically.

WrappedMessage := RegExReplace(LongMessage,"(.{50}\s)","$1`n")

link

like image 114
Avram Avatar answered Nov 16 '22 18:11

Avram


It looks like it isn't supported directly:

How do I word-wrap the Tooltip that is displayed?

Here is a method using Reflection to achieve this.

[ DllImport( "user32.dll" ) ] 
private extern static int SendMessage( IntPtr hwnd, uint msg,
  int wParam, int lParam); 

object o = typeof( ToolTip ).InvokeMember( "Handle",
   BindingFlags.NonPublic | BindingFlags.Instance |
   BindingFlags.GetProperty, 
   null, myToolTip, null ); 
IntPtr hwnd = (IntPtr) o; 
private const uint TTM_SETMAXTIPWIDTH = 0x418;
SendMessage( hwnd, TTM_SETMAXTIPWIDTH, 0, 300 );

Rhett Gong

like image 29
Quartermeister Avatar answered Nov 16 '22 17:11

Quartermeister