private void UpdateRect(WinApi.RECT newRect)
        {
            if (!IsHandleCreated)
            {
                _rect = newRect;
                return;
            }

            WinApi.RECT oldRect = _rect;
            _rect = newRect;
            if (oldRect == newRect)
            {
                return;
            }

            WinApi.User32.SetWindowPosFlags flags = WinApi.User32.SetWindowPosFlags.SWP_NOZORDER | WinApi.User32.SetWindowPosFlags.SWP_NOACTIVATE;
            if (_rect.X == oldRect.X && _rect.Y == oldRect.Y)
            {
                flags |= WinApi.User32.SetWindowPosFlags.SWP_NOMOVE;
            }
            if (_rect.Width == oldRect.Width && _rect.Height == oldRect.Height)
            {
                flags |= WinApi.User32.SetWindowPosFlags.SWP_NOSIZE;
            }

            WinApi.User32.SetWindowPos(Handle, IntPtr.Zero, _rect.X, _rect.Y, _rect.Width, _rect.Height, flags);
        }
Exemple #2
0
        private void UpdateCheckBoxes()
        {
            _suppressingUIToSysUpdate = true;

            var abd = new WinApi.APPBARDATA();

            abd.cbSize = Marshal.SizeOf(abd);
            abd.hWnd   = _taskBarHwnd;

#if false
            abd.uEdge = (uint)WinApi.ABEdge.ABE_BOTTOM;

            var prect    = new WinApi.RECT(0, 0, 1, 1);
            var hMonitor = WinApi.MonitorFromRect(ref prect, (uint)WinApi.MonitorDefault.MONITOR_DEFAULTTONEAREST);

            var monitorInfo = new WinApi.MONITORINFOEX();
            monitorInfo.Size = Marshal.SizeOf(monitorInfo);

            WinApi.GetMonitorInfo(hMonitor, ref monitorInfo);
            abd.rc = monitorInfo.WorkArea;
#endif

            var state = (WinApi.ABState)WinApi.SHAppBarMessage((uint)WinApi.ABMsg.ABM_GETSTATE, ref abd);
            ChkAutoHide.Checked = state == WinApi.ABState.ABS_AUTOHIDE ||
                                  state == WinApi.ABState.ABS_AUTOHIDEANDONTOP;

            ChkAlwaysOnTop.Checked = state == WinApi.ABState.ABS_ALWAYSONTOP ||
                                     state == WinApi.ABState.ABS_AUTOHIDEANDONTOP;

            _suppressingUIToSysUpdate = false;
        }
Exemple #3
0
        /// <summary>
        /// The actual scroll magic is here
        /// </summary>
        private void SetDisplayRectLocation(YamuiScrollHandler scroll, int deltaValue)
        {
            if (deltaValue == 0 || !scroll.HasScroll)
            {
                return;
            }

            // (found in ScrollablePanel.SetDisplayRectLocation(0, deltaVerticalValue);)
            Rectangle cr = ClientRectangle;

            WinApi.RECT rcClip   = WinApi.RECT.FromXYWH(cr.X, cr.Y, cr.Width - scroll.BarThickness, cr.Height);
            WinApi.RECT rcUpdate = WinApi.RECT.FromXYWH(cr.X, cr.Y, cr.Width - scroll.BarThickness, cr.Height);
            WinApi.ScrollWindowEx(
                new HandleRef(this, Handle),
                scroll.IsVertical ? 0 : deltaValue,
                scroll.IsVertical ? deltaValue : 0,
                null,
                ref rcClip,
                WinApi.NullHandleRef,
                ref rcUpdate,
                WinApi.ScrollWindowExFlags.SW_ERASE |
                WinApi.ScrollWindowExFlags.SW_INVALIDATE |
                WinApi.ScrollWindowExFlags.SW_SCROLLCHILDREN |
                WinApi.ScrollWindowExFlags.SW_SMOOTHSCROLL);

            UpdateChildrenBound();

            Refresh(); // not critical but help reduce flickering
        }
        private void NCCalcSize(ref Message m)
        {
            if (m.WParam == IntPtr.Zero)
            {
                WinApi.RECT ncRect   = (WinApi.RECT)m.GetLParam(typeof(WinApi.RECT));
                Rectangle   proposed = ncRect.Rect;

                CalcSizeNCRectangle(ref proposed);

                ncRect.Rect = proposed;
                Marshal.StructureToPtr(ncRect, m.LParam, false);
                m.Result = IntPtr.Zero;
            }
            else if (m.WParam != IntPtr.Zero)
            {
                WinApi.NCCALCSIZE_PARAMS ncParams =
                    (WinApi.NCCALCSIZE_PARAMS)m.GetLParam(typeof(WinApi.NCCALCSIZE_PARAMS));
                Rectangle proposed = ncParams.rect0.Rect;

                CalcSizeNCRectangle(ref proposed);

                ncParams.rect0.Rect = proposed;
                Marshal.StructureToPtr(ncParams, m.LParam, false);
            }
        }
        protected override void WndProc(ref Message m)
        {
            // Send WM_MOUSEWHEEL messages to the parent
            if (!MultiLines && m.Msg == 0x20a)
            {
                WinApi.SendMessage(Parent.Handle, m.Msg, m.WParam, m.LParam);
            }
            else
            {
                base.WndProc(ref m);
            }

            if ((m.Msg == WmPaint) || (m.Msg == OcmCommand))
            {
                // Apply a padding INSIDE the textbox (so we can draw the border!)
                if (!_appliedPadding)
                {
                    WinApi.RECT rc = new WinApi.RECT(4, 2, ClientSize.Width - 8, ClientSize.Height - 3);
                    WinApi.SendMessageRefRect(Handle, WinApi.EM_SETRECT, 0, ref rc);

                    _appliedPadding = true;
                }
                else
                {
                    using (Graphics graphics = CreateGraphics()) {
                        CustomPaint(graphics);
                    }
                }
            }
        }
        /// <summary>
        /// 获取屏保界面可以显示的位置
        /// </summary>
        /// <returns></returns>
        public System.Drawing.Rectangle?GetShowScreenRect()
        {
            System.Drawing.Rectangle?result = null;
            IntPtr hWnd = WinApi.GetForegroundWindow();

            //判断当前全屏的应用是否是桌面
            if (hWnd.Equals(desktopHandle) || hWnd.Equals(shellHandle))
            {
                // 当前前置窗口是桌面或者shell,不存在全屏应用,所以返回主监视器的显示范围
                result = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
            }
            else
            {
                WinApi.RECT rect = new WinApi.RECT();
                WinApi.GetWindowRect(hWnd, ref rect);
                foreach (var screen in System.Windows.Forms.Screen.AllScreens)
                {
                    if (rect.Left != screen.Bounds.Left || rect.Right != screen.Bounds.Right ||//前台窗口在当前监视器上,且是全屏模式,则继续判断下一个监视器
                        rect.Top != screen.Bounds.Top || rect.Bottom < screen.Bounds.Bottom - 5)
                    {
                        result = screen.Bounds;
                        break;
                    }
                }
            }
            return(result);
        }
        /// <summary>
        /// 判断前台窗口是否是全屏
        /// </summary>
        /// <returns></returns>
        public bool TopWinIsFull()
        {
            IntPtr hWnd = WinApi.GetForegroundWindow();

            //判断当前全屏的应用是否是桌面
            if (hWnd.Equals(desktopHandle) || hWnd.Equals(shellHandle))
            {
                return(false);
            }
            else
            {
                WinApi.RECT rect = new WinApi.RECT();
                WinApi.GetWindowRect(hWnd, ref rect);
                int width  = rect.Right - rect.Left;                   //窗口的宽度
                int height = rect.Bottom - rect.Top;                   //窗口的高度
                System.Drawing.Rectangle ScreenArea = System.Windows.Forms.Screen.AllScreens[0].Bounds;
                if (width == ScreenArea.Width && height == ScreenArea.Height &&
                    rect.Left == ScreenArea.Left && rect.Bottom == ScreenArea.Bottom)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Exemple #8
0
        [ThreadStatic] private static ImageAttributes disabledImageAttr; // ImageAttributes used to render disabled images

        public static void DrawFlatCheckBox(Graphics graphics, Rectangle rectangle, Color foreground, Color background, ButtonState state)
        {
            Rectangle offsetRectangle = new Rectangle(rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2);

            //if (checkImage == null || checkImage.Width != rectangle.Width || checkImage.Height != rectangle.Height) {
            //    if (checkImage != null) {
            //        checkImage.Dispose();
            //        checkImage = null;
            //    }


            Bitmap bitmap = new Bitmap(rectangle.Width, rectangle.Height);
            Color  bitmapBackColor;

            using (Graphics g2 = Graphics.FromImage(bitmap)) {
                g2.Clear(Color.Transparent);
                IntPtr dc = g2.GetHdc();
                try {
                    WinApi.RECT rcCheck = WinApi.RECT.FromXYWH(0, 0, rectangle.Width, rectangle.Height);
                    WinApi.DrawFrameControl(new HandleRef(null, dc), ref rcCheck, WinApi.DrawFrameControlTypes.DFC_CAPTION, WinApi.DrawFrameControlStates.DFCS_CAPTIONRESTORE | WinApi.DrawFrameControlStates.DFCS_MONO);
                } finally {
                    g2.ReleaseHdcInternal(dc);
                }
                bitmapBackColor = bitmap.GetPixel(3, 3);
                using (var p = new Pen(bitmapBackColor, 2)) {
                    p.Alignment = PenAlignment.Right;
                    g2.DrawRectangle(p, new Rectangle(1, 1, rectangle.Width - 1, rectangle.Height - 1));
                }
                ImageAttributes attrs2 = new ImageAttributes();
                attrs2.SetRemapTable(new[] {
                    new ColorMap {
                        OldColor = bitmapBackColor,
                        NewColor = Color.White
                    }
                }, ColorAdjustType.Bitmap);
                g2.DrawImage(bitmap, new Rectangle(0, 0, rectangle.Width, rectangle.Height), 0, 0, rectangle.Width, rectangle.Height, GraphicsUnit.Pixel, attrs2);
            }
            //}

            using (var b = new SolidBrush(Color.Black))
                graphics.FillRectangle(b, rectangle);

            //var imgRect = new Rectangle(rectangle.X + 2, rectangle.Y + 2, checkImage.Width - 4, checkImage.Height - 4);
            var             imgRect = rectangle;
            ImageAttributes attrs   = new ImageAttributes();

            attrs.SetRemapTable(new[] {
                new ColorMap {
                    OldColor = Color.Black,
                    NewColor = foreground
                },
                new ColorMap {
                    OldColor = Color.White,
                    NewColor = background
                }
            }, ColorAdjustType.Bitmap);
            graphics.DrawImage(bitmap, imgRect, 0, 0, imgRect.Width, imgRect.Height, GraphicsUnit.Pixel, attrs);
            attrs.Dispose();
        }
Exemple #9
0
    private WinApi.User32.HitTestResult GetWindowEdgeType(WinApi.RECT rect, WinApi.POINT position)
    {
        //if (!rect.Contains(position))
        //    return BorderlessWindow.WindowEdgeType.Client;

        // Normalize coordinates
        position.X -= rect.X;
        position.Y -= rect.Y;

        rect.X = 0;
        rect.Y = 0;

        bool nearTopEdge    = position.Y < TopBorder;
        bool nearLeftEdge   = position.X < LeftBorder;
        bool nearRightEdge  = position.X > rect.Width - RightBorder;
        bool nearBottomEdge = position.Y > rect.Height - BottomBorder;

        if (nearTopEdge)
        {
            if (nearLeftEdge)
            {
                return(WinApi.User32.HitTestResult.HTTOPLEFT);
            }

            if (nearRightEdge)
            {
                return(WinApi.User32.HitTestResult.HTTOPRIGHT);
            }

            return(WinApi.User32.HitTestResult.HTTOP);
        }

        if (nearBottomEdge)
        {
            if (nearLeftEdge)
            {
                return(WinApi.User32.HitTestResult.HTBOTTOMLEFT);
            }

            if (nearRightEdge)
            {
                return(WinApi.User32.HitTestResult.HTBOTTOMRIGHT);
            }

            return(WinApi.User32.HitTestResult.HTBOTTOM);
        }

        if (nearLeftEdge)
        {
            return(WinApi.User32.HitTestResult.HTLEFT);
        }

        if (nearRightEdge)
        {
            return(WinApi.User32.HitTestResult.HTRIGHT);
        }

        return(WinApi.User32.HitTestResult.HTCLIENT);
    }
Exemple #10
0
        internal void SetWindowRect(WinApi.RECT rc)
        {
            bool ignored = this.IgnoreLock;

            this.IgnoreLock = true;
            WinApi.MoveWindow(this.WindowHandle, rc.Left, rc.Top, rc.Right - rc.Left, rc.Bottom - rc.Top, true);
            this.IgnoreLock = ignored;
        }
Exemple #11
0
        /// <summary>
        /// Constructor for playback.
        /// </summary>
        /// <param name="fileName"></param>
        internal MouseRecording(string fileName)
        {
            this.FileName = fileName;
            this.Packets  = new List <Objects.Packet>();
            if (!File.Exists(fileName))
            {
                return;
            }
            using (Stream stream = Utils.TibiaCam.DecompressCamToStream(fileName))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    this._RecorderVersion = reader.ReadUInt16();
                    this.Interval         = reader.ReadUInt16();

                    WinApi.RECT r = new WinApi.RECT();
                    r.left               = 0;
                    r.top                = 0;
                    r.right              = reader.ReadUInt16();
                    r.bottom             = reader.ReadUInt16();
                    this.clientWindowOld = r;

                    WinApi.RECT r2 = new WinApi.RECT();
                    r2.left            = reader.ReadUInt16();
                    r2.top             = reader.ReadUInt16();
                    r2.right           = reader.ReadUInt16();
                    r2.bottom          = reader.ReadUInt16();
                    this.gameWindowOld = r2;

                    while (reader.BaseStream.Position < reader.BaseStream.Length)
                    {
                        Objects.Packet p  = new Objects.Packet();
                        DataType       dt = (DataType)reader.ReadByte();
                        p.AddByte((byte)dt);
                        switch (dt)
                        {
                        case DataType.ClientWindowChange:
                            p.AddUInt16(reader.ReadUInt16());     // width
                            p.AddUInt16(reader.ReadUInt16());     // height
                            break;

                        case DataType.GameWindowChange:
                            p.AddUInt16(reader.ReadUInt16());     // x
                            p.AddUInt16(reader.ReadUInt16());     // y
                            p.AddUInt16(reader.ReadUInt16());     // width
                            p.AddUInt16(reader.ReadUInt16());     // height
                            break;

                        case DataType.MouseXY:
                            p.AddByte(reader.ReadByte());     // mouse %x
                            p.AddByte(reader.ReadByte());     // mouse %y
                            break;
                        }
                        this.Packets.Add(p);
                    }
                }
            }
        }
Exemple #12
0
    private void UpdatePos(WinApi.POINT currentPoint)
    {
        WinApi.POINT delta = new WinApi.POINT(_downMousePos.X - currentPoint.X, _downMousePos.Y - currentPoint.Y);

        WinApi.RECT windowRect = _downWndRect;
        windowRect.X = windowRect.X - delta.X;
        windowRect.Y = windowRect.Y - delta.Y;

        WinApi.User32.SetWindowPos(_ownerForm.Handle, IntPtr.Zero, windowRect.X, windowRect.Y, windowRect.Width, windowRect.Height, 0);
    }
Exemple #13
0
 /// <summary>
 /// Get the window position.
 /// </summary>
 /// <returns>The position.</returns>
 public Vector2 GetPosition()
 {
     if (!IsActive)
     {
         return(Vector2.zero);
     }
     WinApi.RECT rect = new WinApi.RECT();
     WinApi.GetWindowRect(hWnd, out rect);
     return(new Vector2(rect.left, rect.top));
 }
Exemple #14
0
 /// <summary>
 /// Get the window size.
 /// </summary>
 /// <returns>The size.</returns>
 public Vector2 GetSize()
 {
     if (!IsActive)
     {
         return(Vector2.zero);
     }
     WinApi.RECT rect = new WinApi.RECT();
     WinApi.GetWindowRect(hWnd, out rect);
     return(new Vector2(rect.right - rect.left, rect.bottom - rect.top));
 }
Exemple #15
0
        private void AdjustClientArea(ref WinApi.RECT rect)
        {
            if (HorizontalScroll.HasScroll)
            {
                rect.bottom -= HorizontalScroll.BarThickness;
            }

            if (VerticalScroll.HasScroll)
            {
                rect.right -= VerticalScroll.BarThickness;
            }
        }
Exemple #16
0
 private bool OnNcCalcSize_ModifyProposedRectangle(ref WinApi.RECT rect)
 {
     if (IsMaximized)
     {
         var s = Screen.FromHandle(Handle);
         // the proposed rect is the maximized position/size that window suggest using the "out of screen" borders
         // we change that here
         rect.Set(s.WorkingArea);
         return(true);
     }
     return(false);
 }
Exemple #17
0
    /// <summary>
    /// Stores the size and position of the window.
    /// </summary>
    private void StoreWindowSize()
    {
        // 今の状態を記憶
        if (IsActive && !WinApi.IsZoomed(hWnd) && !WinApi.IsIconic(hWnd))
        {
            WinApi.RECT rect = new WinApi.RECT();

            // ウィンドウ位置とサイズ
            WinApi.GetWindowRect(hWnd, out rect);
            this.OriginalWindowPosition = new Vector2(rect.left, rect.top);
            this.OriginalWindowSize     = new Vector2(rect.right - rect.left, rect.bottom - rect.top);
        }
    }
Exemple #18
0
        internal System.Drawing.Point CalculateScreenMouseXY(System.Drawing.Point cursorPercent)
        {
            WinApi.RECT clientBounds     = this.GetClientBounds();
            WinApi.RECT gameWindowBounds = Client.Misc.GameWindow;
            gameWindowBounds.top    += clientBounds.top;
            gameWindowBounds.left   += clientBounds.left;
            gameWindowBounds.right  += gameWindowBounds.left;
            gameWindowBounds.bottom += gameWindowBounds.top;
            int x = (int)Math.Round((gameWindowBounds.right - gameWindowBounds.left) * ((double)cursorPercent.X / (double)100), 0),
                y = (int)Math.Round((gameWindowBounds.bottom - gameWindowBounds.top) * ((double)cursorPercent.Y / (double)100), 0);

            x += gameWindowBounds.left;
            y += gameWindowBounds.top;
            return(new System.Drawing.Point(x, y));
        }
Exemple #19
0
 protected void WinEventCallback(IntPtr hWinEventHook,
                                 Hook.SWEH_Events eventType,
                                 IntPtr hWnd,
                                 Hook.SWEH_ObjectId idObject,
                                 long idChild,
                                 uint dwEventThread,
                                 uint dwmsEventTime)
 {
     if (hWnd == testPic &&
         eventType == Hook.SWEH_Events.EVENT_OBJECT_LOCATIONCHANGE &&
         idObject == (Hook.SWEH_ObjectId)Hook.SWEH_CHILDID_SELF)
     {
         WinApi.RECT rect = Hook.GetWindowRect(hWnd);
         //this.Location = new System.Drawing.Point(rect.Left, rect.Top);
     }
 }
Exemple #20
0
 /// <summary>
 /// Calculates a mouse position based on percentage. X-axis is based on WinApi.RECT.right, Y-axis is based on WinApi.RECT.bottom.
 /// </summary>
 /// <returns></returns>
 internal System.Drawing.Point CalculateMousePercentage()
 {
     WinApi.RECT clientBounds     = this.GetClientBounds();
     WinApi.RECT gameWindowBounds = Client.Misc.GameWindow;
     gameWindowBounds.top    += clientBounds.top;
     gameWindowBounds.left   += clientBounds.left;
     gameWindowBounds.right  += gameWindowBounds.left;
     gameWindowBounds.bottom += gameWindowBounds.top;
     System.Drawing.Point cursorPos = Cursor.Position;
     //Cursor.Position = new System.Drawing.Point(clientBounds.left, clientBounds.top);
     if (cursorPos.X > gameWindowBounds.left && cursorPos.X < gameWindowBounds.right &&
         cursorPos.Y > gameWindowBounds.top && cursorPos.Y < gameWindowBounds.bottom)
     {
         double percentX = ((double)cursorPos.X - (double)gameWindowBounds.left) / ((double)gameWindowBounds.right - (double)gameWindowBounds.left);
         double percentY = ((double)cursorPos.Y - (double)gameWindowBounds.top) / ((double)gameWindowBounds.bottom - (double)gameWindowBounds.top);
         percentX *= 100;
         percentY *= 100;
         return(new System.Drawing.Point((int)Math.Round(percentX, 0), (int)Math.Round(percentY, 0)));
     }
     return(new System.Drawing.Point(0, 0));
 }
        public void Paint()
        {
            IntPtr DC       = ChartArea.bDC;
            IntPtr oldBrush = WinApi.SelectObject(DC, WinApi.GetStockObject(WinApi.StockObjects.DC_BRUSH));
            IntPtr penNull  = WinApi.CreatePen(WinApi.PS_NULL, 1, (uint)ColorTranslator.ToWin32(Color.White));
            IntPtr oldPen   = WinApi.SelectObject(DC, penNull);

            WinApi.SetDCBrushColor(DC, ColorTranslator.ToWin32(backColor));
            WinApi.Rectangle(DC, 0, 0, ChartArea.Width + 1, ChartArea.Height + 1);
            IntPtr hfont   = font.ToHfont();
            IntPtr oldFont = WinApi.SelectObject(DC, hfont);

            WinApi.SetBkMode(DC, WinApi.BkMode.TRANSPARENT);
            WinApi.SetTextColor(DC, ColorTranslator.ToWin32(foreColor));
            if (textHeight == 0)
            {
                WinApi.RECT rect = new WinApi.RECT();
                WinApi.DrawTextW(DC, Headers[0], Headers[0].Length, ref rect, WinApi.DT_CALCRECT);
                nameCaptionWidth = rect.Width;
                textHeight       = rect.Height;
                WinApi.DrawTextW(DC, Headers[5], Headers[5].Length, ref rect, WinApi.DT_CALCRECT);
                maxCaptionWidth = rect.Width + 10;
            }
            int last = Headers.Length;

            for (int i = 0; i < last; i++)
            {
                WinApi.TextOutW(DC, 0, i * textHeight, Headers[i], Headers[i].Length);
            }
            WinApi.TextOutW(DC, nameCaptionWidth, 0, cvalues[0], cvalues[0].Length);
            for (int i = 1; i < last; i++)
            {
                WinApi.TextOutW(DC, maxCaptionWidth, i * textHeight, cvalues[i], cvalues[i].Length);
            }
            WinApi.SelectObject(DC, oldPen);
            WinApi.SelectObject(DC, oldBrush);
            WinApi.SelectObject(DC, oldFont);
            WinApi.DeleteObject(penNull);
            WinApi.DeleteObject(hfont);
        }
Exemple #22
0
    public Test(Form toCover, AxAXVLC.AxVLCPlugin2 ply)
    {
        InitializeComponent();
        WinEventDelegate = new Hook.WinEventDelegate(WinEventCallback);
        this.SetTopLevel(true);
        this.TopMost       = true;
        this.ControlBox    = false;
        this.ShowInTaskbar = false;
        this.StartPosition = FormStartPosition.Manual;
        this.AutoScaleMode = AutoScaleMode.None;
        this.Show(toCover);
        toCover.Focus();

        try
        {
            Target = Process.GetProcessesByName("TestPlayer").FirstOrDefault(p => p != null);
            if (Target != null)
            {
                testPic = Target.MainWindowHandle;
                uint TargetThreadId = Hook.GetWindowThread(testPic);
                if (testPic != IntPtr.Zero)
                {
                    hWinEventHook = Hook.WinEventHookOne(Hook.SWEH_Events.EVENT_OBJECT_LOCATIONCHANGE,
                                                         WinEventDelegate,
                                                         (uint)Target.Id,
                                                         TargetThreadId);
                    rect = Hook.GetWindowRect(testPic);
                }
                if (ply.video.fullscreen == true)
                {
                    Debug.WriteLine("yes is ");
                    this.WindowState = FormWindowState.Maximized;
                }
            }
        }
        catch (Exception e)
        {
            throw e;
        }
    }
    /// <summary>
    /// Stores the size and position of the window.
    /// </summary>
    private void StoreWindowSize()
    {
        // 今の状態を記憶
        if (IsActive && !WinApi.IsZoomed(hWnd) && !WinApi.IsIconic(hWnd))
        {
            //
            WinApi.RECT rect       = new WinApi.RECT();
            WinApi.RECT clientRect = new WinApi.RECT();

            // ウィンドウ位置とサイズ
            WinApi.GetWindowRect(hWnd, out rect);
            this.NormalWindowPosition = new Vector2(rect.left, rect.top);
            this.NormalWindowSize     = new Vector2(rect.right - rect.left, rect.bottom - rect.top);

            // クライアント領域のサイズ
            WinApi.GetClientRect(hWnd, out clientRect);
            this.NormalClientSize = new Vector2(clientRect.right, clientRect.bottom);

            // ウィンドウスタイルを記憶
            this.NormalWindowStyle = WinApi.GetWindowLong(hWnd, WinApi.GWL_STYLE);
        }
    }
Exemple #24
0
        private static void DrawFrameControl(Graphics graphics, int x, int y, int width, int height, WinApi.DrawFrameControlTypes kind, WinApi.DrawFrameControlStates state, Color foreColor, Color backColor)
        {
            WinApi.RECT rcFrame = WinApi.RECT.FromXYWH(0, 0, width, height);
            using (Bitmap bitmap = new Bitmap(width, height)) {
                using (Graphics g2 = Graphics.FromImage(bitmap)) {
                    g2.Clear(Color.Transparent);

                    /* using( WindowsGraphics wg = WindowsGraphics.FromGraphics(g2) ){
                     *  DrawFrameControl(new HandleRef(wg, wg.DeviceContext.Hdc), ref rcFrame, kind, (int) state);  */
                    IntPtr dc = g2.GetHdc();
                    try {
                        WinApi.DrawFrameControl(new HandleRef(null, dc), ref rcFrame, kind, state);
                    } finally {
                        g2.ReleaseHdc();
                    }

                    if (foreColor == Color.Empty || backColor == Color.Empty)
                    {
                        graphics.DrawImage(bitmap, x, y);
                    }
                    else
                    {
                        // Replace black/white with foreColor/backColor.
                        ImageAttributes attrs = new ImageAttributes();
                        ColorMap        cm1   = new ColorMap();
                        cm1.OldColor = Color.Black;
                        cm1.NewColor = foreColor;
                        ColorMap cm2 = new ColorMap();
                        cm2.OldColor = Color.White;
                        cm2.NewColor = backColor;
                        attrs.SetRemapTable(new ColorMap[2] {
                            cm1, cm2
                        }, ColorAdjustType.Bitmap);
                        graphics.DrawImage(bitmap, new Rectangle(x, y, width, height), 0, 0, width, height, GraphicsUnit.Pixel, attrs, null, IntPtr.Zero);
                    }
                }
            }
        }
 private Rectangle GetControlRectangle()
 {
     if (m_Control.IsHandleCreated)
     {
         WinApi.RECT r = new WinApi.RECT();
         WinApi.GetWindowRect(m_Control.Handle, ref r);
         return new Rectangle(0, 0, r.Width, r.Height);
     }
     else
         return new Rectangle(0, 0, m_Control.Width, m_Control.Height);
 }
Exemple #26
0
 public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, ref WinApi.RECT rect, int cPoints);
 /// <summary>
 /// Modify the input rectangle to adjust the client area from the window size
 /// </summary>
 /// <param name="rect"></param>
 protected virtual void AdjustClientArea(ref WinApi.RECT rect)
 {
     // the whole control is a client area
 }
 public void ApplyInternalPadding()
 {
     WinApi.RECT rc = new WinApi.RECT(4, 1, ClientSize.Width - 8, ClientSize.Height - 2);
     WinApi.SendMessageRefRect(Handle, WinApi.EM_SETRECT, 0, ref rc);
 }
Exemple #29
0
        protected override void WndProc(ref Message m)
        {
            const int WM_PAINT = 0xF;
            const int WM_PRINTCLIENT = 0x0318;
            const int WM_CTLCOLORLISTBOX = 0x0134;
            const int CB_ADDSTRING = 0x143;
            const int CB_INSERTSTRING = 0x14A;
            const int CB_DELETESTRING = 0x0144;

            WinApi.RECT rect = new WinApi.RECT();

            switch (m.Msg)
            {
                case WM_CTLCOLORLISTBOX:
                    if (IsMultiColumnDropDown && base.DroppedDown)
                    {
                        BarUtilities.InvokeDelayed(new MethodInvoker(delegate { base.DroppedDown = false; }), 10);
                        break;
                    }

                    if (BarFunctions.IsWindows7 && !IsMultiColumnDropDown)
                    {
                        if (m_DropDownHandle != m.LParam)
                            ReleasePopupHandler();

                        if (_PopupMsgHandler == null)
                            CreatePopupHandler(m.LParam);
                    }

                    m_DropDownHandle = m.LParam;

                    if (!IsMultiColumnDropDown && (m_DropDownHeight > 0 || this.Items.Count == 0))
                    {
                        WinApi.GetWindowRect(m.LParam, ref rect);
                        int height = m_DropDownHeight;
                        if (this.Items.Count == 0)
                            height = Math.Max(18, this.ItemHeight);
                        Point thisLocation = this.PointToScreen(Point.Empty);
                        if (rect.Top < thisLocation.Y)
                            rect.Top = thisLocation.Y + this.Height;
                        NativeFunctions.SetWindowPos(m.LParam, IntPtr.Zero, rect.Left, rect.Top, rect.Width,
                                                     height, NativeFunctions.SWP_NOACTIVATE);
                    }
                    break;

                case (int)WinApi.WindowsMessages.CB_GETDROPPEDSTATE:

                    base.WndProc(ref m);

                    if (m.Result == IntPtr.Zero && DroppedDownInternal && !IsMultiColumnDropDown)
                        DroppedDownInternal = false;
                    return;

                case NativeFunctions.WM_SETFOCUS:
                    if (m.WParam != this.Handle)
                        m_LastFocusWindow = m.WParam;

                    break;

                case CB_ADDSTRING:
                    if (this.Items.Count > 0)
                    {
                        ComboItem cb = this.Items[this.Items.Count - 1] as ComboItem;

                        if (cb != null)
                            cb.m_ComboBox = this;
                    }
                    break;

                case CB_INSERTSTRING:
                    int index = WinApi.ToInt(m.WParam);

                    if (index >= 0 && index < this.Items.Count)
                    {
                        ComboItem cb = this.Items[index] as ComboItem;

                        if (cb != null)
                            cb.m_ComboBox = this;
                    }

                    m_SelectedIndexInternal = -1;
                    break;

                case CB_DELETESTRING:
                    m_SelectedIndexInternal = -1;
                    break;

                case NativeFunctions.WM_USER + 7:
                    if (this.DropDownStyle == ComboBoxStyle.DropDown && !m_Focused)
                        this.SelectionLength = 0;

                    this.Invalidate(true);
                    return;
                case (int)WinApi.WindowsMessages.WM_LBUTTONDOWN:
                    {
                        if (IsMultiColumnDropDown)
                        {
                            if (IsPopupOpen)
                                CloseMultiColumnDropDown();
                            else if (DateTime.Now.Subtract(_MultiDropDownClosedAtTime).TotalMilliseconds > 500 && (this.Focused || this.Focus()))
                            {
                                OpenMultiColumnDropDown();
                            }
                            return; // Don't call base
                        }
                        break;
                    }
                case (int)WinApi.WindowsMessages.WM_REFLECTCOMMAND:
                    {
                        if (IsMultiColumnDropDown)
                        {
                            int wp = WinApi.HIWORD(m.WParam);
                            if (wp == CBN_DROPDOWN)
                            {
                                OpenMultiColumnDropDown();
                                return; // Don't call base
                            }
                            else if (wp == CBN_CLOSEUP)
                            {
                                if (DateTime.Now.Subtract(_MultiDropDownOpenedAtTime).TotalMilliseconds > 900)
                                {
                                    CloseMultiColumnDropDown();
                                    return; // Don't call base
                                }
                            }
                        }
                        break;
                    }
            }

            if (m_DefaultStyle)
            {
                base.WndProc(ref m);
                return;
            }

            if ((m.Msg == WM_PAINT || m.Msg == WM_PRINTCLIENT) && DrawMode != DrawMode.Normal)
            {
                WinApi.GetWindowRect(m.HWnd, ref rect);
                Rectangle r = new Rectangle(0, 0, rect.Width, rect.Height);

                if (m.Msg == WM_PAINT)
                {
                    WinApi.PAINTSTRUCT ps = new WinApi.PAINTSTRUCT();

                    IntPtr hdc = WinApi.BeginPaint(m.HWnd, ref ps);

                    using (Graphics gHdc = Graphics.FromHdc(hdc))
                    {
                        using (BufferedBitmap bmp = new BufferedBitmap(gHdc, r))
                        {
                            PaintComboBox(bmp.Graphics, r);

                            bmp.Render(gHdc);
                        }
                    }

                    WinApi.EndPaint(m.HWnd, ref ps);
                }
                else
                {
                    using (Graphics g = Graphics.FromHdc(m.WParam))
                        PaintComboBox(g, r);
                }

                if (this.Parent is ItemControl)
                    ((ItemControl)this.Parent).UpdateKeyTipsCanvas();
            }
            else
            {
                base.WndProc(ref m);
            }
        }
Exemple #30
0
            protected override void WndProc(ref Message m)
            {
                if (m.Msg == (int)WinApi.WindowsMessages.WM_PAINT)
                {
                    WinApi.PAINTSTRUCT ps = new WinApi.PAINTSTRUCT();
                    IntPtr hdc = WinApi.BeginPaint(m.HWnd, ref ps);
                    try
                    {
                        Graphics g = Graphics.FromHdc(hdc);
                        try
                        {
                            WinApi.RECT r = new WinApi.RECT();
                            WinApi.GetWindowRect(m.HWnd, ref r);
                            Rectangle rc = new Rectangle(0, 0, r.Width, r.Height);
                            using (BufferedBitmap bb = new BufferedBitmap(hdc, rc))
                            {
                                m_Parent.PaintHeaderBackground(bb.Graphics, rc);

                                IList columns = m_Parent.GetOrderedColumnList();

                                int x = 0;
                                foreach (ColumnHeader h in columns)
                                {

                                    Rectangle hr = new Rectangle(x, 0, h.Width, r.Height);
                                    ListViewItemStates state = ListViewItemStates.ShowKeyboardCues;
                                    if (m_MouseDown && hr.Contains(m_MouseDownPoint))
                                    {
                                        Rectangle rt = hr;
                                        rt.Inflate(-6, 0);
                                        if (rt.Contains(m_MouseDownPoint))
                                            state |= ListViewItemStates.Selected;
                                    }

                                    m_Parent.DrawColumnHeaderInternal(new DrawListViewColumnHeaderEventArgs(bb.Graphics, hr, h.DisplayIndex, h,
                                        state, SystemColors.ControlText, Color.Empty, m_Parent.ColumnHeaderFont ?? m_Parent.Font));
                                    x += h.Width;
                                }
                                bb.Render(g);
                            }
                        }
                        finally
                        {
                            g.Dispose();
                        }
                    }
                    finally
                    {
                        WinApi.EndPaint(m.HWnd, ref ps);
                    }
                    return;
                }
                else if (m.Msg == (int)WinApi.WindowsMessages.WM_LBUTTONDOWN)
                {
                    if (m_Parent.HeaderStyle == ColumnHeaderStyle.Clickable)
                    {
                        m_MouseDown = true;
                        m_MouseDownPoint = new Point(WinApi.LOWORD(m.LParam), WinApi.HIWORD(m.LParam));
                        WinApi.RedrawWindow(m.HWnd, IntPtr.Zero, IntPtr.Zero, WinApi.RedrawWindowFlags.RDW_INVALIDATE);
                    }
                }
                else if (m.Msg == (int)WinApi.WindowsMessages.WM_LBUTTONUP)
                {
                    m_MouseDown = false;
                    m_MouseDownPoint = Point.Empty;
                }
                else if (m.Msg == (int)WinApi.WindowsMessages.WM_MOUSEMOVE && m_MouseDown)
                {
                    m_MouseDownPoint = new Point(WinApi.LOWORD(m.LParam), WinApi.HIWORD(m.LParam));
                }

                base.WndProc(ref m);
            }
Exemple #31
0
        private Rectangle GetWatermarkBounds()
        {
            if (this.DropDownStyle != ComboBoxStyle.DropDownList && m_TextWindowMsgHandler != null)
            {
                WinApi.RECT rect = new WinApi.RECT();
                WinApi.GetWindowRect(m_TextWindowMsgHandler.Handle, ref rect);
                return new Rectangle(0, 0, rect.Width, rect.Height);
            }

            Rectangle r = new Rectangle(2, 0, this.Width - 2, this.Height);
            r.Inflate(-2, -1);
            int thumbSize = SystemInformation.HorizontalScrollBarThumbWidth;
            r.Width -= thumbSize;
            if (this.RightToLeft == RightToLeft.Yes)
                r.X += thumbSize;

            return r;
        }
Exemple #32
0
        private void MouseOverTimerTick(object sender, EventArgs e)
        {
            bool over = false;

            if (this.IsHandleCreated && this.Visible)
            {
                WinApi.RECT rw = new WinApi.RECT();
                WinApi.GetWindowRect(this.Handle, ref rw);
                Rectangle r = rw.ToRectangle();
                if (r.Contains(Control.MousePosition))
                    over = true;
                Point p = this.PointToClient(Control.MousePosition);
                if (m_ThumbRect.Contains(p))
                    MouseOverThumb = true;
                else
                    MouseOverThumb = false;
            }

            if (!over)
            {
                SetMouseOverTimerEnabled(false);
                m_MouseOver = false;
                UpdateBackColor();
                this.Invalidate();
                if (this.ParentItem != null) this.ParentItem.HideToolTip();
            }
        }
Exemple #33
0
        private Rectangle GetControlRect(Control c)
        {
            if (!c.IsHandleCreated) return Rectangle.Empty;

            WinApi.RECT rect = new WinApi.RECT();
            WinApi.GetWindowRect(c.Handle, ref rect);
            Point p = this.PointToClient(rect.Location);
            return new Rectangle(p, rect.Size);

            //Point p = c.PointToScreen(Point.Empty);
            //p = this.PointToClient(p);
            //return new Rectangle(p, c.Size);
        }
Exemple #34
0
        internal NonClientInfo GetNonClientInfo()
        {
            WinApi.RECT rect = new WinApi.RECT(0, 0, 200, 200);
            CreateParams params1 = this.CreateParams;
            WinApi.AdjustWindowRectEx(ref rect, params1.Style, false, params1.ExStyle);

            NonClientInfo n = new NonClientInfo();
            n.CaptionTotalHeight = Math.Abs(rect.Top);
            n.BottomBorder = rect.Height - 200 - n.CaptionTotalHeight;
            n.LeftBorder = Math.Abs(rect.Left);
            n.RightBorder = rect.Width - 200 - n.LeftBorder;

            return n;
        }
 /// <summary>
 /// Gets the window position.
 /// </summary>
 /// <returns>The position.</returns>
 public Vector2 GetPosition()
 {
     if (!IsActive) return Vector2.zero;
     WinApi.RECT rect = new WinApi.RECT();
     WinApi.GetWindowRect(hWnd, out rect);
     return new Vector2(rect.left, rect.top);
 }
 /// <summary>
 /// Gets the window size.
 /// </summary>
 /// <returns>The size.</returns>
 public Vector2 GetSize()
 {
     if (!IsActive) return Vector2.zero;
     WinApi.RECT rect = new WinApi.RECT();
     WinApi.GetWindowRect(hWnd, out rect);
     return new Vector2(rect.right - rect.left, rect.bottom - rect.top);
 }
    /// <summary>
    /// Stores the size and position of the window.
    /// </summary>
    private void StoreWindowSize()
    {
        // 今の状態を記憶
        if (IsActive && !WinApi.IsZoomed(hWnd) && !WinApi.IsIconic(hWnd)) {
            //
            WinApi.RECT rect = new WinApi.RECT();
            WinApi.RECT clientRect = new WinApi.RECT();

            // ウィンドウ位置とサイズ
            WinApi.GetWindowRect(hWnd, out rect);
            this.NormalWindowPosition = new Vector2(rect.left, rect.top);
            this.NormalWindowSize = new Vector2(rect.right - rect.left, rect.bottom - rect.top);

            // クライアント領域のサイズ
            WinApi.GetClientRect(hWnd, out clientRect);
            this.NormalClientSize = new Vector2(clientRect.right, clientRect.bottom);

            // ウィンドウスタイルを記憶
            this.NormalWindowStyle = WinApi.GetWindowLong (hWnd, WinApi.GWL_STYLE);
        }
    }
Exemple #38
0
 private void ThreadRecord()
 {
     try
     {
         this.Packets = new List <Objects.Packet>();
         Objects.Packet meta = new Objects.Packet();
         meta.AddUInt16((ushort)Settings.CurrentVersion); // recorder version
         meta.AddUInt16(Settings.Tibiacam.Recorder.MouseInterval);
         WinApi.RECT clientRect = new WinApi.RECT();
         WinApi.GetClientRect(Client.Tibia.MainWindowHandle, out clientRect);
         this.clientWindowOld = clientRect;
         //meta.AddUInt16((ushort)clientRect.left);
         //meta.AddUInt16((ushort)clientRect.top);
         meta.AddUInt16((ushort)clientRect.right);
         meta.AddUInt16((ushort)clientRect.bottom);
         WinApi.RECT r = Client.Misc.GameWindow;
         this.gameWindowOld = r;
         meta.AddUInt16((ushort)r.left);
         meta.AddUInt16((ushort)r.top);
         meta.AddUInt16((ushort)r.right);
         meta.AddUInt16((ushort)r.bottom);
         this.Packets.Add(meta);
         this.Interval = Settings.Tibiacam.Recorder.MouseInterval;
         while (isRecording)
         {
             Objects.Packet p;
             WinApi.RECT    newClientRect = new WinApi.RECT();
             WinApi.GetClientRect(Client.Tibia.MainWindowHandle, out newClientRect);
             if (newClientRect.right != this.clientWindowOld.right ||
                 newClientRect.bottom != this.clientWindowOld.bottom)
             {
                 p = new Objects.Packet();
                 this.clientWindowOld = newClientRect;
                 p.AddByte((byte)DataType.ClientWindowChange);
                 p.AddUInt16((ushort)newClientRect.right);
                 p.AddUInt16((ushort)newClientRect.bottom);
                 this.Packets.Add(p);
                 continue;
             }
             WinApi.RECT newRect = Client.Misc.GameWindow;
             if (this.gameWindowOld.left != newRect.left ||
                 this.gameWindowOld.bottom != newRect.bottom)
             {
                 p = new Objects.Packet();
                 this.gameWindowOld = newRect;
                 p.AddByte((byte)DataType.GameWindowChange);
                 p.AddUInt16((ushort)newRect.left);
                 p.AddUInt16((ushort)newRect.top);
                 p.AddUInt16((ushort)newRect.right);
                 p.AddUInt16((ushort)newRect.bottom);
                 this.Packets.Add(p);
                 continue;
             }
             p = new Objects.Packet();
             System.Drawing.Point mousePercentage = this.CalculateMousePercentage();
             p.AddByte((byte)DataType.MouseXY);
             if (WinApi.GetForegroundWindow() == Client.Tibia.MainWindowHandle)
             {
                 p.AddByte((byte)mousePercentage.X);
                 p.AddByte((byte)mousePercentage.Y);
             }
             else
             {
                 p.AddByte(0);
                 p.AddByte(0);
             }
             this.Packets.Add(p);
             Thread.Sleep(this.Interval);
         }
     }
     catch (Exception ex) { MessageBox.Show("Mouse recording error:\n" + ex.Message + "\n" + ex.StackTrace); }
     isRecording = false;
 }
Exemple #39
0
        static void Main(string[] args)
        {
            IntPtr handle = Process.GetCurrentProcess().MainWindowHandle;

            SetConsoleMode(handle, ENABLE_EXTENDED_FLAGS);



            const string appName = "Test App";
            const string wndName = "Test App Window";

            ApplicationContext applicationContext = new ApplicationContext();

            Form form1 = new Form(applicationContext);

            form1.Text  = "ololo";
            form1.Text += "GG";
            WinApi.RECT rect = form1.Rect;
            rect.Width  = 300;
            rect.Height = 200;
            form1.Rect  = rect;
            form1.Show();
            form1.Text += "GG";
            //Form form2 = new Form(applicationContext);
            //form2.Text = "ololo";
            //form2.Text += "GG2";
            //rect = form2.Rect;
            //rect.Width = 500;
            //rect.Height = 400;
            //form2.Rect = rect;
            //form2.Show();


            applicationContext.Run();
            return;

            IntPtr hThisInst = WinApi.Kernel32.GetModuleHandle(null);

            _wndProc = WndProc;

            WinApi.User32.WNDCLASSEX wndClassEx = new WinApi.User32.WNDCLASSEX();
            wndClassEx.cbSize        = WinApi.User32.WNDCLASSEX.SizeOf;
            wndClassEx.style         = WinApi.User32.WindowClassStyles.CS_HREDRAW | WinApi.User32.WindowClassStyles.CS_VREDRAW;
            wndClassEx.lpfnWndProc   = _wndProc;
            wndClassEx.cbClsExtra    = 0;
            wndClassEx.cbWndExtra    = 0;
            wndClassEx.hInstance     = IntPtr.Zero;
            wndClassEx.hIcon         = WinApi.User32.LoadIcon(WinApi.User32.IconId.IDI_SHIELD);
            wndClassEx.hIconSm       = WinApi.User32.LoadIcon(WinApi.User32.IconId.IDI_SHIELD);
            wndClassEx.hCursor       = WinApi.User32.LoadCursor(WinApi.User32.CursorId.IDC_ARROW);
            wndClassEx.hbrBackground = new IntPtr((int)WinApi.User32.SystemColorId.COLOR_WINDOW);
            wndClassEx.lpszClassName = "test app";

            if (WinApi.User32.RegisterClassEx(ref wndClassEx) == 0)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            _hWnd = WinApi.User32.CreateWindowEx(
                WinApi.User32.WindowStylesEx.WS_EX_TOPMOST,
                "test app",
                wndName,
                WinApi.User32.WindowStyles.WS_VISIBLE | WinApi.User32.WindowStyles.WS_OVERLAPPEDWINDOW,
                200, 150,
                300, 200,
                IntPtr.Zero,
                IntPtr.Zero,
                hThisInst,
                IntPtr.Zero);

            if (_hWnd == IntPtr.Zero)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            WinApi.MSG message;

            bool isExit = false;

            //while (!isExit) {
            //while (WinApi.User32.PeekMessage(out message, IntPtr.Zero, 0, 0, WinApi.User32.PeekMessageOptions.PM_NOREMOVE)) {
            while (WinApi.User32.GetMessage(out message, _hWnd, 0, 0) > 0)
            {
                WinApi.User32.TranslateMessage(ref message);
                WinApi.User32.DispatchMessage(ref message);
            }
            //}

            Console.WriteLine("end");
            Console.ReadLine();
        }
Exemple #40
0
        private bool GetIsVisible(Control control)
        {
            if (!control.Visible) return false;
            if (control.Parent == null || !control.IsHandleCreated) return control.Visible;

            WinApi.RECT rect = new WinApi.RECT();
            WinApi.GetWindowRect(control.Handle, ref rect);
            Point pp = control.Parent.PointToClient(new Point(rect.Left + 3, rect.Top + 3));
            IntPtr handle = NativeFunctions.ChildWindowFromPoint(control.Parent.Handle, new NativeFunctions.POINT(pp.X, pp.Y));
            if (handle == IntPtr.Zero) return control.Visible;

            Control c = Control.FromHandle(handle);
            if (c != null && c != control && c != this && c != control.Parent)
            {
                return false;
            }

            return control.Visible;
        }
Exemple #41
0
        protected virtual void AdjustBounds(ref int width, ref int height, BoundsSpecified specified)
        {
            WinApi.RECT rect = new WinApi.RECT(0, 0, width, height);
            CreateParams params1 = this.CreateParams;
            WinApi.AdjustWindowRectEx(ref rect, params1.Style, false, params1.ExStyle);

            if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height)
            {
                height -= (rect.Height - height);
                //if (IsGlassEnabled)
                //{
                //    if (this.FormBorderStyle == FormBorderStyle.FixedDialog)
                //        height += SystemInformation.FixedFrameBorderSize.Height;
                //    else if (this.FormBorderStyle == FormBorderStyle.Fixed3D)
                //        height += SystemInformation.FixedFrameBorderSize.Height;
                //    else if (this.FormBorderStyle == FormBorderStyle.FixedSingle)
                //        height += 1;
                //    else if (this.FormBorderStyle == FormBorderStyle.FixedToolWindow)
                //        height += SystemInformation.FixedFrameBorderSize.Height;
                //    else
                //        height += SystemInformation.FrameBorderSize.Height /* * NativeFunctions.BorderMultiplierFactor*/;
                //}
            }

            if ((specified & BoundsSpecified.Width) == BoundsSpecified.Width)
            {
                width -= (rect.Width - width);
            }
        }