예제 #1
0
        internal static void PositionTooltip(Control parent, GridToolTip ToolTip, Rectangle itemRect) {
            ToolTip.Visible = false;
            
            NativeMethods.RECT rect = NativeMethods.RECT.FromXYWH(itemRect.X, itemRect.Y, itemRect.Width, itemRect.Height);

            ToolTip.SendMessage(NativeMethods.TTM_ADJUSTRECT, 1, ref rect);

            // now offset it back to screen coords
            Point locPoint = parent.PointToScreen(new Point(rect.left, rect.top));
            
            ToolTip.Location = locPoint;   // set the position once so it updates it's size with it's real width.
            
            int overHang =  (ToolTip.Location.X + ToolTip.Size.Width) - SystemInformation.VirtualScreen.Width;
            if (overHang > 0) {
                locPoint.X -= overHang;
                ToolTip.Location = locPoint;
            }

            // tell the control we've repositioned it.
            ToolTip.Visible = true;  
        }
 internal static void PositionTooltip(Control parent, GridToolTip ToolTip, Rectangle itemRect)
 {
     ToolTip.Visible = false;
     System.Windows.Forms.NativeMethods.RECT lparam = System.Windows.Forms.NativeMethods.RECT.FromXYWH(itemRect.X, itemRect.Y, itemRect.Width, itemRect.Height);
     ToolTip.SendMessage(0x41f, 1, ref lparam);
     Point point = parent.PointToScreen(new Point(lparam.left, lparam.top));
     ToolTip.Location = point;
     int num = (ToolTip.Location.X + ToolTip.Size.Width) - SystemInformation.VirtualScreen.Width;
     if (num > 0)
     {
         point.X -= num;
         ToolTip.Location = point;
     }
     ToolTip.Visible = true;
 }