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);
 }
        // 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 (toolTipString == null)
                throw new ArgumentNullException("toolTipString");
            if (iconBounds.IsEmpty)
                throw new ArgumentNullException("iconBounds", SR.GetString(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;
            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);
        }
Esempio n. 3
0
File: Form.cs Progetto: mind0n/hive
 private NativeMethods.TOOLINFO_T GetTOOLINFO() {
     NativeMethods.TOOLINFO_T toolInfo;
     toolInfo = new NativeMethods.TOOLINFO_T();
     toolInfo.cbSize = Marshal.SizeOf(typeof(NativeMethods.TOOLINFO_T));
     toolInfo.uFlags |= NativeMethods.TTF_SUBCLASS;
     toolInfo.lpszText =  this.toolTipText;
     if (owner.RightToLeft == RightToLeft.Yes) {
         toolInfo.uFlags |= NativeMethods.TTF_RTLREADING;
     }
     if (!first) {
         toolInfo.uFlags |= NativeMethods.TTF_TRANSPARENT;
         toolInfo.hwnd = owner.Handle;
         Size s = SystemInformation.CaptionButtonSize;
         Rectangle r = new Rectangle(owner.Left, owner.Top, s.Width, SystemInformation.CaptionHeight);
         r = owner.RectangleToClient(r);
         r.Width -= r.X;
         r.Y += 1;
         toolInfo.rect = NativeMethods.RECT.FromXYWH(r.X, r.Y, r.Width, r.Height);
         toolInfo.uId = IntPtr.Zero;
     }
     else {
         toolInfo.uFlags |= NativeMethods.TTF_IDISHWND | NativeMethods.TTF_TRACK;
         toolInfo.hwnd = IntPtr.Zero;
         toolInfo.uId = owner.Handle;
     }
     return toolInfo;
 }
Esempio n. 4
0
 /// <include file='doc\StatusBar.uex' path='docs/doc[@for="StatusBar.ControlToolTip.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>
 private NativeMethods.TOOLINFO_T GetMinTOOLINFO(Tool tool) {
     NativeMethods.TOOLINFO_T ti = new NativeMethods.TOOLINFO_T();
     ti.cbSize = Marshal.SizeOf(typeof(NativeMethods.TOOLINFO_T));
     ti.hwnd = parent.Handle;
     if ((int)tool.id < 0) {
         AssignId(tool);
     }
     StatusBar p = (StatusBar)parent;
     if (p != null && p.ToolTipSet) {
        ti.uId = parent.Handle; 
     }
     else {
         ti.uId = tool.id;
     }
     return ti;
 }
Esempio n. 5
0
            //
            // METHODS
            //

            /// <include file='doc\ErrorProvider.uex' path='docs/doc[@for="ErrorProvider.ErrorWindow.Add"]/*' />
            /// <devdoc>
            ///     This is called when a control would like to show an error icon.
            /// </devdoc>
            public void Add(ControlItem item) {
                items.Add(item);
                if (!EnsureCreated())
                {
                    return;
                }

                NativeMethods.TOOLINFO_T toolInfo = new NativeMethods.TOOLINFO_T();
                toolInfo.cbSize = Marshal.SizeOf(toolInfo);
                toolInfo.hwnd = Handle;
                toolInfo.uId = item.Id;
                toolInfo.lpszText = item.Error;
                toolInfo.uFlags = NativeMethods.TTF_SUBCLASS;
                UnsafeNativeMethods.SendMessage(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.TTM_ADDTOOL, 0, toolInfo);

                Update(false /*timerCaused*/);
            }
Esempio n. 6
0
            /// <include file='doc\ErrorProvider.uex' path='docs/doc[@for="ErrorProvider.ErrorWindow.Update"]/*' />
            /// <devdoc>
            ///     Move and size the error window, compute and set the window region,
            ///     set the tooltip rectangles and descriptions.  This basically brings
            ///     the error window up to date with the internal data structures.
            /// </devdoc>
            public void Update(bool timerCaused) {
                IconRegion iconRegion = provider.Region;
                Size size = iconRegion.Size;
                windowBounds = Rectangle.Empty;
                for (int i = 0; i < items.Count; i++) {
                    ControlItem item = (ControlItem)items[i];
                    Rectangle iconBounds = item.GetIconBounds(size);
                    if (windowBounds.IsEmpty)
                        windowBounds = iconBounds;
                    else
                        windowBounds = Rectangle.Union(windowBounds, iconBounds);
                }

                Region windowRegion =  new Region(new Rectangle(0, 0, 0, 0));
                IntPtr windowRegionHandle = IntPtr.Zero;
                try {
                    for (int i = 0; i < items.Count; i++) {
                        ControlItem item = (ControlItem)items[i];
                        Rectangle iconBounds = item.GetIconBounds(size);
                        iconBounds.X -= windowBounds.X;
                        iconBounds.Y -= windowBounds.Y;

                        bool showIcon = true;
                        if (!item.ToolTipShown) {
                            switch (provider.BlinkStyle) {
                                case ErrorBlinkStyle.NeverBlink:
                                    // always show icon
                                    break;

                                case ErrorBlinkStyle.BlinkIfDifferentError:
                                    showIcon = (item.BlinkPhase == 0) || (item.BlinkPhase > 0 && (item.BlinkPhase & 1) == (i & 1));
                                    break;

                                case ErrorBlinkStyle.AlwaysBlink:
                                    showIcon = ((i & 1) == 0) == provider.showIcon;
                                    break;
                            }
                        }

                        if (showIcon)
                        {
                            iconRegion.Region.Translate(iconBounds.X, iconBounds.Y);
                            windowRegion.Union(iconRegion.Region);
                            iconRegion.Region.Translate(-iconBounds.X, -iconBounds.Y);
                        }

                        if (tipWindow != null) {
                            NativeMethods.TOOLINFO_T toolInfo = new NativeMethods.TOOLINFO_T();
                            toolInfo.cbSize = Marshal.SizeOf(toolInfo);
                            toolInfo.hwnd = Handle;
                            toolInfo.uId = item.Id;
                            toolInfo.lpszText = item.Error;
                            toolInfo.rect = NativeMethods.RECT.FromXYWH(iconBounds.X, iconBounds.Y, iconBounds.Width, iconBounds.Height);
                            toolInfo.uFlags = NativeMethods.TTF_SUBCLASS;
                            if (provider.RightToLeft) {
                                toolInfo.uFlags |= NativeMethods.TTF_RTLREADING;
                            }
                            UnsafeNativeMethods.SendMessage(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.TTM_SETTOOLINFO, 0, toolInfo);
                        }

                        if (timerCaused && item.BlinkPhase > 0) {
                            item.BlinkPhase--;
                        }
                    }
                    if (timerCaused) {
                        provider.showIcon = !provider.showIcon;
                    }


                    DeviceContext dc = null;
                    dc = DeviceContext.FromHwnd(this.Handle);
                    try {
                        CreateMirrorDC(dc.Hdc, windowBounds.Width);
                        
                        Graphics graphics = Graphics.FromHdcInternal(mirrordc.Hdc);
                        try {
                            windowRegionHandle = windowRegion.GetHrgn(graphics);
                            System.Internal.HandleCollector.Add(windowRegionHandle, NativeMethods.CommonHandles.GDI);
                        }
                        finally {
                            graphics.Dispose();
                            RestoreMirrorDC();
                        }
                        
                        if (UnsafeNativeMethods.SetWindowRgn(new HandleRef(this, Handle), new HandleRef(windowRegion, windowRegionHandle), true) != 0) {
                            //The HWnd owns the region.
                            windowRegionHandle = IntPtr.Zero;
                        }
                    }
                    
                    finally {
                        if (dc != null) {
                            dc.Dispose();
                        }
                    }

                }
                finally {
                    windowRegion.Dispose();
                    if (windowRegionHandle != IntPtr.Zero) {
                        SafeNativeMethods.DeleteObject(new HandleRef(null, windowRegionHandle));
                    }
                }

                SafeNativeMethods.SetWindowPos(new HandleRef(this, Handle), NativeMethods.HWND_TOP, windowBounds.X, windowBounds.Y,
                                     windowBounds.Width, windowBounds.Height, NativeMethods.SWP_NOACTIVATE);
                SafeNativeMethods.InvalidateRect(new HandleRef(this, Handle), null, false);
            }
Esempio n. 7
0
            /// <include file='doc\ErrorProvider.uex' path='docs/doc[@for="ErrorProvider.ErrorWindow.Remove"]/*' />
            /// <devdoc>
            ///     This is called when a control no longer needs to display an error icon.
            /// </devdoc>
            public void Remove(ControlItem item) {
                items.Remove(item);

                if (tipWindow != null) {
                    NativeMethods.TOOLINFO_T toolInfo = new NativeMethods.TOOLINFO_T();
                    toolInfo.cbSize = Marshal.SizeOf(toolInfo);
                    toolInfo.hwnd = Handle;
                    toolInfo.uId = item.Id;
                    UnsafeNativeMethods.SendMessage(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.TTM_DELTOOL, 0, toolInfo);
                }

                if (items.Count == 0) {
                    EnsureDestroyed();
                }
                else {
                    Update(false /*timerCaused*/);
                }
            }
Esempio n. 8
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(typeof(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];
 }