private void AddTool() { TOOLINFO tool = new TOOLINFO { lpszText = CommCtrl.LPSTR_TEXTCALLBACK }; tool = this.ExecuteTool(CommCtrl.TTM_ADDTOOL, ref tool); }
private TOOLINFO ExecuteTool(int message, ref TOOLINFO Tool) { Tool.cbSize = Marshal.SizeOf((TOOLINFO) Tool); Tool.uFlags = TTF.TTF_IDISHWND; Tool.hwnd = base.Handle; Tool.uId = base.Handle; GCHandle handle = GCHandle.Alloc((TOOLINFO) Tool, GCHandleType.Pinned); try { Windows.SendMessage(this.TooltipWnd, CommCtrl.TTM_ADDTOOL, IntPtr.Zero, handle.AddrOfPinnedObject()); } finally { handle.Free(); } return Tool; }
private void DeleteTool() { TOOLINFO tool = new TOOLINFO(); tool = this.ExecuteTool(CommCtrl.TTM_DELTOOL, ref tool); }
private void CreateTool() { //System.Diagnostics.Debug.Assert( // m_parent.Handle!=IntPtr.Zero, // "parent hwnd is null", "SetToolTip"); CreateParams cp = new CreateParams(); cp.ClassName = TOOLTIPS_CLASS; cp.Style = WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP | TTS_CLOSE; // create the tool m_tool.CreateHandle(cp); // create and fill in the tool tip info ti = new TOOLINFO(); ti.cbSize = Marshal.SizeOf(ti); ti.uFlags = TTF_TRACK | TTF_IDISHWND | TTF_TRANSPARENT | TTF_SUBCLASS | TTF_PARSELINKS; // absolute is used tooltip maynot be shown // if coords exceed the corners of the screen //if(m_absPosn) //{ // ti.uFlags |= //TTF_ABSOLUTE; //} if(m_centerStem) { ti.uFlags |= TTF_CENTERTIP; } ti.uId = m_tool.Handle; ti.lpszText = m_text; //ti.hwnd = m_parent.Handle; //GetClientRect(m_parent.Handle, ref ti.rect); //ClientToScreen(m_parent.Handle, ref ti.rect); // make sure we make it the top level window SetWindowPos( m_tool.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); //int scopeInitInfoSize = Marshal.SizeOf(typeof(DSOP_SCOPE_INIT_INFO)); //int offset = scopeInitInfoSize; //IntPtr scopeInitInfo = (IntPtr)(refScopeInitInfo.ToInt64() + offset); // add the tool tip IntPtr ptrStruct = Marshal.AllocHGlobal(Marshal.SizeOf(ti)); Marshal.StructureToPtr(ti, ptrStruct, false); SendMessage( m_tool.Handle, TTM_ADDTOOL, 0, ptrStruct); ti = (TOOLINFO)Marshal.PtrToStructure(ptrStruct, typeof(TOOLINFO)); SendMessage( m_tool.Handle, TTM_SETMAXTIPWIDTH, 0, new IntPtr(m_maxWidth)); //IntPtr ptrTitle = Marshal.StringToHGlobalAuto(m_title); //SendMessage( // m_tool.Handle, TTM_SETTITLE, // (int)m_titleIcon, ptrTitle); SetBalloonPosition(ti.rect); Marshal.FreeHGlobal(ptrStruct); //Marshal.FreeHGlobal(ptrTitle); }