tags:

views:

52

answers:

2

How to wordwrap text that need to be appear in ToolTip

+1  A: 

It looks like it isn't supported directly. There is a workaround at http://windowsclient.net/blogs/faqs/archive/2006/05/26/how-do-i-word-wrap-the-tooltip-that-is-displayed.aspx:

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; 
SendMessage( hwnd, 0x0418, 0, 300 );

Rhett Gong

Quartermeister
A: 

another way, is to create regexp that wrapping automatically.

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

link

Avram