예제 #1
0
 public void RemoveToolTip(IntPtr toolTipId)
 {
     NativeMethods.TOOLINFO_T toolInfo = new NativeMethods.TOOLINFO_T();
     toolInfo.cbSize = Marshal.SizeOf(toolInfo);
     toolInfo.hwnd   = dataGrid.Handle;
     toolInfo.uId    = toolTipId;
     UnsafeNativeMethods.SendMessage(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.TTM_DELTOOL, 0, toolInfo);
 }
예제 #2
0
 /// <include file='doc\ToolTip.uex' path='docs/doc[@for="ToolTip.GetMinTOOLINFO"]/*' />
 /// <devdoc>
 ///     Returns a new instance of the TOOLINFO_T structure with the minimum
 ///     required data to uniquely identify a region. This is used primarily
 ///     for delete operations. NOTE: This cannot force the creation of a handle.
 /// </devdoc>
 /// <internalonly/>
 private NativeMethods.TOOLINFO_T GetMinTOOLINFO(Control ctl)
 {
     NativeMethods.TOOLINFO_T ti = new NativeMethods.TOOLINFO_T();
     ti.cbSize  = Marshal.SizeOf(typeof(NativeMethods.TOOLINFO_T));
     ti.hwnd    = IntPtr.Zero;
     ti.uFlags |= NativeMethods.TTF_IDISHWND;
     ti.uId     = ctl.Handle;
     return(ti);
 }
예제 #3
0
        // this function will add a toolTip to the
        // windows system
        public void AddToolTip(string toolTipString, IntPtr toolTipId, Rectangle iconBounds)
        {
            Debug.Assert(tipWindow != null && tipWindow.Handle != IntPtr.Zero, "the tipWindow was not initialized, bailing out");
            if (iconBounds.IsEmpty)
            {
                throw new ArgumentNullException(nameof(iconBounds), SR.DataGridToolTipEmptyIcon);
            }

            NativeMethods.TOOLINFO_T toolInfo = new NativeMethods.TOOLINFO_T();
            toolInfo.cbSize   = Marshal.SizeOf(toolInfo);
            toolInfo.hwnd     = dataGrid.Handle;
            toolInfo.uId      = toolTipId;
            toolInfo.lpszText = toolTipString ?? throw new ArgumentNullException(nameof(toolTipString));
            toolInfo.rect     = NativeMethods.RECT.FromXYWH(iconBounds.X, iconBounds.Y, iconBounds.Width, iconBounds.Height);
            toolInfo.uFlags   = NativeMethods.TTF_SUBCLASS;
            UnsafeNativeMethods.SendMessage(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.TTM_ADDTOOL, 0, toolInfo);
        }
예제 #4
0
        private NativeMethods.TOOLINFO_T GetTOOLINFO(Control c)
        {
            int index = Array.IndexOf(controls, c);

            Debug.Assert(index != -1, "Failed to find control in tooltip array");

            if (toolInfos[index] == null)
            {
                toolInfos[index]         = new NativeMethods.TOOLINFO_T();
                toolInfos[index].cbSize  = Marshal.SizeOf <NativeMethods.TOOLINFO_T>();
                toolInfos[index].uFlags |= NativeMethods.TTF_IDISHWND | NativeMethods.TTF_TRANSPARENT | NativeMethods.TTF_SUBCLASS;
            }
            toolInfos[index].lpszText = this.toolTipText;
            toolInfos[index].hwnd     = c.Handle;
            toolInfos[index].uId      = c.Handle;
            return(toolInfos[index]);
        }
예제 #5
0
        /// <include file='doc\ToolTip.uex' path='docs/doc[@for="ToolTip.GetTOOLINFO"]/*' />
        /// <devdoc>
        ///     Returns a detailed TOOLINFO_T structure that represents the specified
        ///     region. NOTE: This may force the creation of a handle.
        /// </devdoc>
        /// <internalonly/>
        private NativeMethods.TOOLINFO_T GetTOOLINFO(Control ctl, string caption)
        {
            NativeMethods.TOOLINFO_T ti = GetMinTOOLINFO(ctl);
            ti.cbSize  = Marshal.SizeOf(typeof(NativeMethods.TOOLINFO_T));
            ti.uFlags |= NativeMethods.TTF_TRANSPARENT | NativeMethods.TTF_SUBCLASS;

            // RightToLeft reading order
            //
            Control richParent = TopLevelControl;

            if (richParent != null && richParent.RightToLeft == RightToLeft.Yes)
            {
                ti.uFlags |= NativeMethods.TTF_RTLREADING;
            }

            ti.lpszText = caption;
            return(ti);
        }