コード例 #1
0
 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);
     }
 }
コード例 #2
0
 public void SetBits()
 {
     if (this.BackgroundImage != null)
     {
         Bitmap bitmap = new Bitmap(this.BackgroundImage, base.Width, base.Height);
         if (!Image.IsCanonicalPixelFormat(bitmap.PixelFormat) || !Image.IsAlphaPixelFormat(bitmap.PixelFormat))
         {
             throw new ApplicationException("图片必须是32位带Alhpa通道的图片。");
         }
         IntPtr oldBits = IntPtr.Zero;
         IntPtr screenDC = CCWin.Win32.NativeMethods.GetDC(IntPtr.Zero);
         IntPtr hBitmap = IntPtr.Zero;
         IntPtr memDc = CCWin.Win32.NativeMethods.CreateCompatibleDC(screenDC);
         try
         {
             CCWin.Win32.NativeMethods.Point topLoc = new CCWin.Win32.NativeMethods.Point(base.Left, base.Top);
             CCWin.Win32.NativeMethods.Size bitMapSize = new CCWin.Win32.NativeMethods.Size(base.Width, base.Height);
             CCWin.Win32.NativeMethods.BLENDFUNCTION blendFunc = new CCWin.Win32.NativeMethods.BLENDFUNCTION();
             CCWin.Win32.NativeMethods.Point srcLoc = new CCWin.Win32.NativeMethods.Point(0, 0);
             hBitmap = bitmap.GetHbitmap(Color.FromArgb(0));
             oldBits = CCWin.Win32.NativeMethods.SelectObject(memDc, hBitmap);
             blendFunc.BlendOp = 0;
             blendFunc.SourceConstantAlpha = byte.Parse("255");
             blendFunc.AlphaFormat = 1;
             blendFunc.BlendFlags = 0;
             CCWin.Win32.NativeMethods.UpdateLayeredWindow(base.Handle, screenDC, ref topLoc, ref bitMapSize, memDc, ref srcLoc, 0, ref blendFunc, 2);
         }
         finally
         {
             if (hBitmap != IntPtr.Zero)
             {
                 CCWin.Win32.NativeMethods.SelectObject(memDc, oldBits);
                 CCWin.Win32.NativeMethods.DeleteObject(hBitmap);
             }
             CCWin.Win32.NativeMethods.ReleaseDC(IntPtr.Zero, screenDC);
             CCWin.Win32.NativeMethods.DeleteDC(memDc);
         }
     }
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 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);
     }
 }
コード例 #5
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));
     }
 }
コード例 #6
0
 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;
 }