public void RemoveToolTip(IntPtr toolTipId)
 {
     System.Windows.Forms.NativeMethods.TOOLINFO_T toolinfo_t;
     toolinfo_t = new System.Windows.Forms.NativeMethods.TOOLINFO_T {
         cbSize = Marshal.SizeOf(toolinfo_t),
         hwnd = this.dataGrid.Handle,
         uId = toolTipId
     };
     System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.tipWindow, this.tipWindow.Handle), System.Windows.Forms.NativeMethods.TTM_DELTOOL, 0, toolinfo_t);
 }
예제 #2
0
 public void RemoveToolTip(IntPtr toolTipId)
 {
     System.Windows.Forms.NativeMethods.TOOLINFO_T toolinfo_t;
     toolinfo_t = new System.Windows.Forms.NativeMethods.TOOLINFO_T {
         cbSize = Marshal.SizeOf(toolinfo_t),
         hwnd   = this.dataGrid.Handle,
         uId    = toolTipId
     };
     System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.tipWindow, this.tipWindow.Handle), System.Windows.Forms.NativeMethods.TTM_DELTOOL, 0, toolinfo_t);
 }
        private System.Windows.Forms.NativeMethods.TOOLINFO_T GetTOOLINFO(Control c)
        {
            int index = Array.IndexOf <Control>(this.controls, c);

            if (this.toolInfos[index] == null)
            {
                this.toolInfos[index]        = new System.Windows.Forms.NativeMethods.TOOLINFO_T();
                this.toolInfos[index].cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.TOOLINFO_T));
                System.Windows.Forms.NativeMethods.TOOLINFO_T toolinfo_t1 = this.toolInfos[index];
                toolinfo_t1.uFlags |= 0x111;
            }
            this.toolInfos[index].lpszText = this.toolTipText;
            this.toolInfos[index].hwnd     = c.Handle;
            this.toolInfos[index].uId      = c.Handle;
            return(this.toolInfos[index]);
        }
 public void AddToolTip(string toolTipString, IntPtr toolTipId, Rectangle iconBounds)
 {
     System.Windows.Forms.NativeMethods.TOOLINFO_T toolinfo_t;
     if (toolTipString == null)
     {
         throw new ArgumentNullException("toolTipString");
     }
     if (iconBounds.IsEmpty)
     {
         throw new ArgumentNullException("iconBounds", System.Windows.Forms.SR.GetString("DataGridToolTipEmptyIcon"));
     }
     toolinfo_t = new System.Windows.Forms.NativeMethods.TOOLINFO_T {
         cbSize = Marshal.SizeOf(toolinfo_t),
         hwnd = this.dataGrid.Handle,
         uId = toolTipId,
         lpszText = toolTipString,
         rect = System.Windows.Forms.NativeMethods.RECT.FromXYWH(iconBounds.X, iconBounds.Y, iconBounds.Width, iconBounds.Height),
         uFlags = 0x10
     };
     System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.tipWindow, this.tipWindow.Handle), System.Windows.Forms.NativeMethods.TTM_ADDTOOL, 0, toolinfo_t);
 }
예제 #5
0
 public void AddToolTip(string toolTipString, IntPtr toolTipId, Rectangle iconBounds)
 {
     System.Windows.Forms.NativeMethods.TOOLINFO_T toolinfo_t;
     if (toolTipString == null)
     {
         throw new ArgumentNullException("toolTipString");
     }
     if (iconBounds.IsEmpty)
     {
         throw new ArgumentNullException("iconBounds", System.Windows.Forms.SR.GetString("DataGridToolTipEmptyIcon"));
     }
     toolinfo_t = new System.Windows.Forms.NativeMethods.TOOLINFO_T {
         cbSize   = Marshal.SizeOf(toolinfo_t),
         hwnd     = this.dataGrid.Handle,
         uId      = toolTipId,
         lpszText = toolTipString,
         rect     = System.Windows.Forms.NativeMethods.RECT.FromXYWH(iconBounds.X, iconBounds.Y, iconBounds.Width, iconBounds.Height),
         uFlags   = 0x10
     };
     System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.tipWindow, this.tipWindow.Handle), System.Windows.Forms.NativeMethods.TTM_ADDTOOL, 0, toolinfo_t);
 }
 private System.Windows.Forms.NativeMethods.TOOLINFO_T GetTOOLINFO()
 {
     System.Windows.Forms.NativeMethods.TOOLINFO_T toolinfo_t;
     toolinfo_t = new System.Windows.Forms.NativeMethods.TOOLINFO_T {
         cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.TOOLINFO_T)),
         uFlags = toolinfo_t.uFlags | 0x10,
         lpszText = this.toolTipText
     };
     if (this.owner.RightToLeft == RightToLeft.Yes)
     {
         toolinfo_t.uFlags |= 4;
     }
     if (!this.first)
     {
         toolinfo_t.uFlags |= 0x100;
         toolinfo_t.hwnd = this.owner.Handle;
         Size captionButtonSize = SystemInformation.CaptionButtonSize;
         Rectangle r = new Rectangle(this.owner.Left, this.owner.Top, captionButtonSize.Width, SystemInformation.CaptionHeight);
         r = this.owner.RectangleToClient(r);
         r.Width -= r.X;
         r.Y++;
         toolinfo_t.rect = System.Windows.Forms.NativeMethods.RECT.FromXYWH(r.X, r.Y, r.Width, r.Height);
         toolinfo_t.uId = IntPtr.Zero;
         return toolinfo_t;
     }
     toolinfo_t.uFlags |= 0x21;
     toolinfo_t.hwnd = IntPtr.Zero;
     toolinfo_t.uId = this.owner.Handle;
     return toolinfo_t;
 }
 private System.Windows.Forms.NativeMethods.TOOLINFO_T GetMinTOOLINFO(Tool tool)
 {
     System.Windows.Forms.NativeMethods.TOOLINFO_T toolinfo_t = new System.Windows.Forms.NativeMethods.TOOLINFO_T {
         cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.TOOLINFO_T)),
         hwnd = this.parent.Handle
     };
     if (((int) tool.id) < 0)
     {
         this.AssignId(tool);
     }
     StatusBar parent = (StatusBar) this.parent;
     if ((parent != null) && parent.ToolTipSet)
     {
         toolinfo_t.uId = this.parent.Handle;
         return toolinfo_t;
     }
     toolinfo_t.uId = tool.id;
     return toolinfo_t;
 }
 public void Add(ErrorProvider.ControlItem item)
 {
     this.items.Add(item);
     if (this.EnsureCreated())
     {
         System.Windows.Forms.NativeMethods.TOOLINFO_T toolinfo_t;
         toolinfo_t = new System.Windows.Forms.NativeMethods.TOOLINFO_T {
             cbSize = Marshal.SizeOf(toolinfo_t),
             hwnd = base.Handle,
             uId = item.Id,
             lpszText = item.Error,
             uFlags = 0x10
         };
         System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.tipWindow, this.tipWindow.Handle), System.Windows.Forms.NativeMethods.TTM_ADDTOOL, 0, toolinfo_t);
         this.Update(false);
     }
 }
            public void Update(bool timerCaused)
            {
                ErrorProvider.IconRegion region = this.provider.Region;
                Size size = region.Size;
                this.windowBounds = Rectangle.Empty;
                for (int i = 0; i < this.items.Count; i++)
                {
                    Rectangle iconBounds = ((ErrorProvider.ControlItem) this.items[i]).GetIconBounds(size);
                    if (this.windowBounds.IsEmpty)
                    {
                        this.windowBounds = iconBounds;
                    }
                    else
                    {
                        this.windowBounds = Rectangle.Union(this.windowBounds, iconBounds);
                    }
                }
                Region wrapper = new Region(new Rectangle(0, 0, 0, 0));
                IntPtr zero = IntPtr.Zero;
                try
                {
                    for (int j = 0; j < this.items.Count; j++)
                    {
                        ErrorProvider.ControlItem item2 = (ErrorProvider.ControlItem) this.items[j];
                        Rectangle rectangle2 = item2.GetIconBounds(size);
                        rectangle2.X -= this.windowBounds.X;
                        rectangle2.Y -= this.windowBounds.Y;
                        bool flag = true;
                        if (!item2.ToolTipShown)
                        {
                            switch (this.provider.BlinkStyle)
                            {
                                case ErrorBlinkStyle.BlinkIfDifferentError:
                                    flag = (item2.BlinkPhase == 0) || ((item2.BlinkPhase > 0) && ((item2.BlinkPhase & 1) == (j & 1)));
                                    break;

                                case ErrorBlinkStyle.AlwaysBlink:
                                    flag = ((j & 1) == 0) == this.provider.showIcon;
                                    break;
                            }
                        }
                        if (flag)
                        {
                            region.Region.Translate(rectangle2.X, rectangle2.Y);
                            wrapper.Union(region.Region);
                            region.Region.Translate(-rectangle2.X, -rectangle2.Y);
                        }
                        if (this.tipWindow != null)
                        {
                            System.Windows.Forms.NativeMethods.TOOLINFO_T toolinfo_t;
                            toolinfo_t = new System.Windows.Forms.NativeMethods.TOOLINFO_T {
                                cbSize = Marshal.SizeOf(toolinfo_t),
                                hwnd = base.Handle,
                                uId = item2.Id,
                                lpszText = item2.Error,
                                rect = System.Windows.Forms.NativeMethods.RECT.FromXYWH(rectangle2.X, rectangle2.Y, rectangle2.Width, rectangle2.Height),
                                uFlags = 0x10
                            };
                            if (this.provider.RightToLeft)
                            {
                                toolinfo_t.uFlags |= 4;
                            }
                            System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.tipWindow, this.tipWindow.Handle), System.Windows.Forms.NativeMethods.TTM_SETTOOLINFO, 0, toolinfo_t);
                        }
                        if (timerCaused && (item2.BlinkPhase > 0))
                        {
                            item2.BlinkPhase--;
                        }
                    }
                    if (timerCaused)
                    {
                        this.provider.showIcon = !this.provider.showIcon;
                    }
                    DeviceContext context = null;
                    using (context = DeviceContext.FromHwnd(base.Handle))
                    {
                        this.CreateMirrorDC(context.Hdc, this.windowBounds.Width);
                        Graphics g = Graphics.FromHdcInternal(this.mirrordc.Hdc);
                        try
                        {
                            zero = wrapper.GetHrgn(g);
                            System.Internal.HandleCollector.Add(zero, System.Windows.Forms.NativeMethods.CommonHandles.GDI);
                        }
                        finally
                        {
                            g.Dispose();
                            this.RestoreMirrorDC();
                        }
                        if (System.Windows.Forms.UnsafeNativeMethods.SetWindowRgn(new HandleRef(this, base.Handle), new HandleRef(wrapper, zero), true) != 0)
                        {
                            zero = IntPtr.Zero;
                        }
                    }
                }
                finally
                {
                    wrapper.Dispose();
                    if (zero != IntPtr.Zero)
                    {
                        System.Windows.Forms.SafeNativeMethods.DeleteObject(new HandleRef(null, zero));
                    }
                }
                System.Windows.Forms.SafeNativeMethods.SetWindowPos(new HandleRef(this, base.Handle), System.Windows.Forms.NativeMethods.HWND_TOP, this.windowBounds.X, this.windowBounds.Y, this.windowBounds.Width, this.windowBounds.Height, 0x10);
                System.Windows.Forms.SafeNativeMethods.InvalidateRect(new HandleRef(this, base.Handle), (System.Windows.Forms.NativeMethods.COMRECT) null, false);
            }
 public void Remove(ErrorProvider.ControlItem item)
 {
     this.items.Remove(item);
     if (this.tipWindow != null)
     {
         System.Windows.Forms.NativeMethods.TOOLINFO_T toolinfo_t;
         toolinfo_t = new System.Windows.Forms.NativeMethods.TOOLINFO_T {
             cbSize = Marshal.SizeOf(toolinfo_t),
             hwnd = base.Handle,
             uId = item.Id
         };
         System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.tipWindow, this.tipWindow.Handle), System.Windows.Forms.NativeMethods.TTM_DELTOOL, 0, toolinfo_t);
     }
     if (this.items.Count == 0)
     {
         this.EnsureDestroyed();
     }
     else
     {
         this.Update(false);
     }
 }