private void CreateTool() { System.Diagnostics.Debug.Assert( mToolP.Handle != IntPtr.Zero, "parent hwnd is null", "SetToolTip"); CreateParams cp = new CreateParams(); cp.ClassName = TOOLTIPS_CLASS; cp.Style = WS_POPUP | TTS_BALLOON | TTS_NOPREFIX | TTS_ALWAYSTIP | TTS_CLOSE; mTool.CreateHandle(cp); ti = new TOOLINFO(); ti.cbSize = Marshal.SizeOf(ti); ti.uFlags = TTF_TRACK | TTF_IDISHWND | TTF_TRANSPARENT | TTF_SUBCLASS | TTF_PARSELINKS; if (tipmPos) { ti.uFlags |= TTF_ABSOLUTE; } if (tipmCen) { ti.uFlags |= TTF_CENTERTIP; } ti.uId = mTool.Handle; ti.lpszText = tipmText; ti.hwnd = mToolP.Handle; GetClientRect(mToolP.Handle, ref ti.rect); ClientToScreen(mToolP.Handle, ref ti.rect); SetWindowPos( mTool.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); IntPtr ptrStruct = Marshal.AllocHGlobal(Marshal.SizeOf(ti)); Marshal.StructureToPtr(ti, ptrStruct, true); SendMessage( mTool.Handle, TTM_ADDTOOL, 0, ptrStruct); ti = (TOOLINFO)Marshal.PtrToStructure(ptrStruct, typeof(TOOLINFO)); SendMessage( mTool.Handle, TTM_SETMAXTIPWIDTH, 0, new IntPtr(mtoolMax)); IntPtr ptrTitle = Marshal.StringToHGlobalAuto(tipmTitle); SendMessage( mTool.Handle, TTM_SETTITLE, (int)tipmTI, ptrTitle); SetPos(ti.rect); Marshal.FreeHGlobal(ptrStruct); Marshal.FreeHGlobal(ptrTitle); }