public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref TOOLINFO lParam);
private void TooltipAction( Control ctrl, string text, TToolAction action ) { if( ctrl.Parent != null ) { AttachToParent( ctrl.Parent.Handle ); Rectangle clientRect = new Rectangle( ctrl.Location, ctrl.Size ); TOOLINFO info = new TOOLINFO(); info.cbSize = (uint)Marshal.SizeOf( typeof( TOOLINFO ) ); info.uFlags = (uint)ToolTipFlags.TTF_IDISHWND | (uint)ToolTipFlags.TTF_SUBCLASS; info.hwnd = ctrl.Parent.Handle; info.uId = ctrl.Handle; info.lpszText = text; //( text != null ) ? Marshal.StringToHGlobalAuto( text ) : IntPtr.Zero; info.rect = (RECT)clientRect; int msg = 0; switch( action ) { case TToolAction.INSERT: msg = (int)ToolTipMsg.TTM_ADDTOOLW; Trace.WriteLine( "Add", "TOOL ACTION" ); break; case TToolAction.UPDATE: msg = (int)ToolTipMsg.TTM_UPDATETIPTEXTW; Trace.WriteLine( "Update Text", "TOOL ACTION" ); break; case TToolAction.REMOVE: msg = (int)ToolTipMsg.TTM_DELTOOLW; Trace.WriteLine( "Add", "TOOL ACTION" ); break; } int result = WindowsAPI.SendMessage( m_tooltip.Handle, msg, 0, ref info ); if( result == 0 ) { Trace.WriteLine( "Tool Action status FAIL!!!", "Notification" ); } } }
public static extern int SendMessage( IntPtr hWnd, int msg, int wParam, ref TOOLINFO lParam );