public void RemoveToolTip(IWin32Window window) { const int TTM_DELTOOL = 0x433; NativeMethods.TOOLINFO lParam = this.GetTOOLINFO(window); NativeMethods.SendMessageTOOLINFO(this.Handle, TTM_DELTOOL, 0, lParam); }
public void AddTool(IWin32Window window) { const int TTM_ADDTOOL = 0x432; NativeMethods.SendMessage(this.Handle, 0x418, 0, SystemInformation.MaxWindowTrackSize.Width); NativeMethods.TOOLINFO lParam = this.GetTOOLINFO(window); IntPtr result = NativeMethods.SendMessageTOOLINFO(this.Handle, TTM_ADDTOOL, 0, lParam); }
/// <summary> /// Make a TOOLINFO structure for the given window /// </summary> /// <param name="window"></param> /// <returns>A filled in TOOLINFO</returns> private NativeMethods.TOOLINFO MakeToolInfoStruct(IWin32Window window) { NativeMethods.TOOLINFO toolinfo_tooltip = new NativeMethods.TOOLINFO(); toolinfo_tooltip.hwnd = window.Handle; toolinfo_tooltip.uFlags = TTF_IDISHWND | TTF_SUBCLASS; toolinfo_tooltip.uId = window.Handle; toolinfo_tooltip.lpszText = (IntPtr)(-1); // LPSTR_TEXTCALLBACK return(toolinfo_tooltip); }
internal NativeMethods.TOOLINFO GetTOOLINFO(IWin32Window window) { const int TTF_IDISHWND = 1; //const int TTF_ABSOLUTE = 0x80; //const int TTF_CENTERTIP = 2; const int TTF_SUBCLASS = 0x10; //const int TTF_TRACK = 0x20; //const int TTF_TRANSPARENT = 0x100; NativeMethods.TOOLINFO toolinfo_tooltip = new NativeMethods.TOOLINFO(); toolinfo_tooltip.hwnd = window.Handle; toolinfo_tooltip.uFlags = TTF_IDISHWND | TTF_SUBCLASS; toolinfo_tooltip.uId = window.Handle; toolinfo_tooltip.lpszText = (IntPtr)(-1); // LPSTR_TEXTCALLBACK return(toolinfo_tooltip); }
/// <summary> /// Make a TOOLINFO structure for the given window /// </summary> /// <param name="window"></param> /// <returns>A filled in TOOLINFO</returns> private NativeMethods.TOOLINFO MakeToolInfoStruct(IWin32Window window) { NativeMethods.TOOLINFO toolinfo_tooltip = new NativeMethods.TOOLINFO(); toolinfo_tooltip.hwnd = window.Handle; toolinfo_tooltip.uFlags = TTF_IDISHWND | TTF_SUBCLASS; toolinfo_tooltip.uId = window.Handle; toolinfo_tooltip.lpszText = (IntPtr)(-1); // LPSTR_TEXTCALLBACK return toolinfo_tooltip; }
//public void Munge() { // NativeMethods.TOOLINFO tool = new NativeMethods.TOOLINFO(); // IntPtr result = NativeMethods.SendMessageTOOLINFO(this.Handle, TTM_GETCURRENTTOOL, 0, tool); // System.Diagnostics.Trace.WriteLine("-"); // System.Diagnostics.Trace.WriteLine(result); // result = NativeMethods.SendMessageTOOLINFO(this.Handle, TTM_GETBUBBLESIZE, 0, tool); // System.Diagnostics.Trace.WriteLine(String.Format("{0} {1}", result.ToInt32() >> 16, result.ToInt32() & 0xFFFF)); // NativeMethods.ChangeSize(this, result.ToInt32() & 0xFFFF, result.ToInt32() >> 16); // //NativeMethods.RECT r = new NativeMethods.RECT(); // //r.right // //IntPtr x = NativeMethods.SendMessageRECT(this.Handle, TTM_ADJUSTRECT, true, ref r); // //System.Diagnostics.Trace.WriteLine(String.Format("{0} {1} {2} {3}", r.left, r.top, r.right, r.bottom)); //} /// <summary> /// Remove the given window from those managed by this tooltip /// </summary> /// <param name="window"></param> public void RemoveToolTip(IWin32Window window) { NativeMethods.TOOLINFO lParam = this.MakeToolInfoStruct(window); NativeMethods.SendMessageTOOLINFO(this.Handle, TTM_DELTOOL, 0, lParam); }
SendMessageTOOLINFO(IntPtr hWnd, int Msg, int wParam, NativeMethods.TOOLINFO lParam);
public static extern IntPtr SendMessageTOOLINFO(IntPtr hWnd, int Msg, int wParam, NativeMethods.TOOLINFO lParam);
/// <summary> /// Add the given window to those for whom this tooltip will show tips /// </summary> /// <param name="window">The window</param> public void AddTool(IWin32Window window) { NativeMethods.TOOLINFO lParam = MakeToolInfoStruct(window); NativeMethods.SendMessageTOOLINFO(Handle, TTM_ADDTOOL, 0, lParam); }