Ejemplo n.º 1
0
 public TOOLINFO(int flags)
 {
     this.cbSize = Marshal.SizeOf(typeof(TOOLINFO));
     this.uFlags = flags;
     this.hwnd = IntPtr.Zero;
     this.uId = IntPtr.Zero;
     this.rect = new RECT(0, 0, 0, 0);
     this.hinst = IntPtr.Zero;
     this.lpszText = IntPtr.Zero;
     this.lParam = IntPtr.Zero;
 }
 internal void CheckBounds(IntPtr hWnd)
 {
     CCWin.Win32.Struct.RECT controlRect = new CCWin.Win32.Struct.RECT();
     CCWin.Win32.Struct.RECT maskRect = new CCWin.Win32.Struct.RECT();
     CCWin.Win32.NativeMethods.GetWindowRect(base.Handle, ref maskRect);
     CCWin.Win32.NativeMethods.GetWindowRect(hWnd, ref controlRect);
     uint uFlag = 0x214;
     if (!CCWin.Win32.NativeMethods.EqualRect(ref controlRect, ref maskRect))
     {
         CCWin.Win32.NativeMethods.Point point = new CCWin.Win32.NativeMethods.Point(controlRect.Left, controlRect.Top);
         CCWin.Win32.NativeMethods.ScreenToClient(CCWin.Win32.NativeMethods.GetParent(base.Handle), ref point);
         CCWin.Win32.NativeMethods.SetWindowPos(base.Handle, IntPtr.Zero, point.x, point.y, controlRect.Right - controlRect.Left, controlRect.Bottom - controlRect.Top, uFlag);
     }
 }
 internal void CreateParamsInternal(IntPtr hWnd)
 {
     IntPtr hParent = CCWin.Win32.NativeMethods.GetParent(hWnd);
     CCWin.Win32.Struct.RECT rect = new CCWin.Win32.Struct.RECT();
     CCWin.Win32.NativeMethods.Point point = new CCWin.Win32.NativeMethods.Point();
     CCWin.Win32.NativeMethods.GetWindowRect(hWnd, ref rect);
     point.x = rect.Left;
     point.y = rect.Top;
     CCWin.Win32.NativeMethods.ScreenToClient(hParent, ref point);
     int dwStyle = 0x5400000d;
     int dwExStyle = 0x88;
     this._createParams = new System.Windows.Forms.CreateParams();
     this._createParams.Parent = hParent;
     this._createParams.ClassName = "STATIC";
     this._createParams.Caption = null;
     this._createParams.Style = dwStyle;
     this._createParams.ExStyle = dwExStyle;
     this._createParams.X = point.x;
     this._createParams.Y = point.y;
     this._createParams.Width = rect.Right - rect.Left;
     this._createParams.Height = rect.Bottom - rect.Top;
 }
Ejemplo n.º 4
0
 private void FoundAndDrawWindowRect()
 {
     CCWin.Win32.NativeMethods.Point pt = new CCWin.Win32.NativeMethods.Point();
     pt.x = Control.MousePosition.X;
     pt.y = Control.MousePosition.Y;
     IntPtr hWnd = CCWin.Win32.NativeMethods.ChildWindowFromPointEx(CCWin.Win32.NativeMethods.GetDesktopWindow(), pt, 3);
     if (hWnd != IntPtr.Zero)
     {
         IntPtr hTemp = hWnd;
         while (true)
         {
             CCWin.Win32.NativeMethods.ScreenToClient(hTemp, ref pt);
             hTemp = CCWin.Win32.NativeMethods.ChildWindowFromPointEx(hTemp, pt, 0);
             if ((hTemp == IntPtr.Zero) || (hTemp == hWnd))
             {
                 break;
             }
             hWnd = hTemp;
             pt.x = Control.MousePosition.X;
             pt.y = Control.MousePosition.Y;
         }
         CCWin.Win32.Struct.RECT rect = new CCWin.Win32.Struct.RECT();
         CCWin.Win32.NativeMethods.GetWindowRect(hWnd, ref rect);
         this.imgpb.SetSelectRect(new Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top));
     }
 }
 public static extern bool AdjustWindowRectEx(ref RECT lpRect, int dwStyle, bool bMenu, int dwExStyle);
 public static extern bool ValidateRect(IntPtr hWnd, ref RECT lpRect);
 public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref RECT lParam);
 public static extern int RtlMoveMemory(ref CCWin.Win32.Struct.POINT destination, ref RECT Source, int length);
Ejemplo n.º 9
0
 public static void CreateRegion(IntPtr hWnd, int radius, RoundStyle roundStyle, bool redraw)
 {
     CCWin.Win32.Struct.RECT bounds = new CCWin.Win32.Struct.RECT();
     CCWin.Win32.NativeMethods.GetWindowRect(hWnd, ref bounds);
     Rectangle rect = new Rectangle(System.Drawing.Point.Empty, bounds.Size);
     if (roundStyle != RoundStyle.None)
     {
         using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, radius, roundStyle, true))
         {
             using (Region region = new Region(path))
             {
                 path.Widen(Pens.White);
                 region.Union(path);
                 IntPtr hDc = CCWin.Win32.NativeMethods.GetWindowDC(hWnd);
                 try
                 {
                     using (Graphics g = Graphics.FromHdc(hDc))
                     {
                         CCWin.Win32.NativeMethods.SetWindowRgn(hWnd, region.GetHrgn(g), redraw);
                     }
                 }
                 finally
                 {
                     CCWin.Win32.NativeMethods.ReleaseDC(hWnd, hDc);
                 }
             }
             return;
         }
     }
     IntPtr hRgn = CCWin.Win32.NativeMethods.CreateRectRgn(0, 0, rect.Width, rect.Height);
     CCWin.Win32.NativeMethods.SetWindowRgn(hWnd, hRgn, redraw);
 }
 public static extern bool PtInRect(ref RECT lprc, Point pt);
 public static extern int OffsetRect(ref RECT lpRect, int x, int y);
 public static extern bool InvalidateRect(IntPtr hWnd, ref RECT rect, bool erase);
 public static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
 public static extern bool GetClientRect(IntPtr hWnd, ref RECT r);
 private ScrollBarHistTest ScrollBarHitTest(IntPtr hWnd)
 {
     CCWin.Win32.NativeMethods.Point point = new CCWin.Win32.NativeMethods.Point();
     CCWin.Win32.Struct.RECT rect = new CCWin.Win32.Struct.RECT();
     System.Drawing.Point thumbPoint = this.GetScrollBarThumb();
     int arrowCx = this.ArrowCx;
     int arrowCy = this.ArrowCy;
     CCWin.Win32.NativeMethods.GetWindowRect(hWnd, ref rect);
     CCWin.Win32.NativeMethods.OffsetRect(ref rect, -rect.Left, -rect.Top);
     CCWin.Win32.Struct.RECT tp = rect;
     CCWin.Win32.NativeMethods.GetCursorPos(ref point);
     CCWin.Win32.NativeMethods.ScreenToClient(hWnd, ref point);
     if (this.Direction == Orientation.Horizontal)
     {
         if (CCWin.Win32.NativeMethods.PtInRect(ref rect, point))
         {
             tp.Right = arrowCx;
             if (CCWin.Win32.NativeMethods.PtInRect(ref tp, point))
             {
                 return ScrollBarHistTest.LeftArrow;
             }
             tp.Left = rect.Right - arrowCx;
             tp.Right = rect.Right;
             if (CCWin.Win32.NativeMethods.PtInRect(ref tp, point))
             {
                 return ScrollBarHistTest.RightArrow;
             }
             if (this._owner.RightToLeft == RightToLeft.Yes)
             {
                 tp.Left = point.y;
                 tp.Right = point.x;
             }
             else
             {
                 tp.Left = thumbPoint.X;
                 tp.Right = thumbPoint.Y;
             }
             if (CCWin.Win32.NativeMethods.PtInRect(ref tp, point))
             {
                 return ScrollBarHistTest.Thumb;
             }
             return ScrollBarHistTest.Track;
         }
     }
     else if (CCWin.Win32.NativeMethods.PtInRect(ref rect, point))
     {
         tp.Bottom = arrowCy;
         if (CCWin.Win32.NativeMethods.PtInRect(ref tp, point))
         {
             return ScrollBarHistTest.TopArrow;
         }
         tp.Top = rect.Bottom - arrowCy;
         tp.Bottom = rect.Bottom;
         if (CCWin.Win32.NativeMethods.PtInRect(ref tp, point))
         {
             return ScrollBarHistTest.BottomArrow;
         }
         tp.Top = thumbPoint.X;
         tp.Bottom = thumbPoint.Y;
         if (CCWin.Win32.NativeMethods.PtInRect(ref tp, point))
         {
             return ScrollBarHistTest.Thumb;
         }
         return ScrollBarHistTest.Track;
     }
     return ScrollBarHistTest.None;
 }
 private void CalculateRect(IntPtr scrollBarHWnd, bool bHorizontal, out Rectangle bounds, out Rectangle trackRect, out Rectangle topLeftArrowRect, out Rectangle bottomRightArrowRect, out Rectangle thumbRect)
 {
     CCWin.Win32.Struct.RECT rect = new CCWin.Win32.Struct.RECT();
     CCWin.Win32.NativeMethods.GetWindowRect(scrollBarHWnd, ref rect);
     CCWin.Win32.NativeMethods.OffsetRect(ref rect, -rect.Left, -rect.Top);
     int arrowWidth = bHorizontal ? this.ArrowCx : this.ArrowCy;
     bounds = rect.Rect;
     System.Drawing.Point point = this.GetScrollBarThumb(bounds, bHorizontal, arrowWidth);
     trackRect = bounds;
     if (bHorizontal)
     {
         topLeftArrowRect = new Rectangle(0, 0, arrowWidth, bounds.Height);
         bottomRightArrowRect = new Rectangle(bounds.Width - arrowWidth, 0, arrowWidth, bounds.Height);
         if (this._owner.RightToLeft == RightToLeft.Yes)
         {
             thumbRect = new Rectangle(point.Y, 0, point.X - point.Y, bounds.Height);
         }
         else
         {
             thumbRect = new Rectangle(point.X, 0, point.Y - point.X, bounds.Height);
         }
     }
     else
     {
         topLeftArrowRect = new Rectangle(0, 0, bounds.Width, arrowWidth);
         bottomRightArrowRect = new Rectangle(0, bounds.Height - arrowWidth, bounds.Width, arrowWidth);
         thumbRect = new Rectangle(0, point.X, bounds.Width, point.Y - point.X);
     }
 }
 private void DrawUpDownButton()
 {
     bool mouseOver = false;
     bool mousePress = this.LeftKeyPressed();
     bool mouseInUpButton = false;
     Rectangle clipRect = this._upDownButton.ClientRectangle;
     CCWin.Win32.Struct.RECT windowRect = new CCWin.Win32.Struct.RECT();
     CCWin.Win32.NativeMethods.Point cursorPoint = new CCWin.Win32.NativeMethods.Point();
     CCWin.Win32.NativeMethods.GetCursorPos(ref cursorPoint);
     CCWin.Win32.NativeMethods.GetWindowRect(this._upDownButtonWnd, ref windowRect);
     mouseOver = CCWin.Win32.NativeMethods.PtInRect(ref windowRect, cursorPoint);
     cursorPoint.x -= windowRect.Left;
     cursorPoint.y -= windowRect.Top;
     mouseInUpButton = cursorPoint.y < (clipRect.Height / 2);
     using (Graphics g = Graphics.FromHwnd(this._upDownButtonWnd))
     {
         UpDownButtonPaintEventArgs e = new UpDownButtonPaintEventArgs(g, clipRect, mouseOver, mousePress, mouseInUpButton);
         this._owner.OnPaintUpDownButton(e);
     }
 }
 public static extern bool RedrawWindow(IntPtr hWnd, ref RECT rectUpdate, IntPtr hrgnUpdate, int flags);