private void AdjustWindowSize() { if (_settings.WindowSize.IsEmpty) { _settings.WindowSize = new Size( _settings.GameWindow.ClientSize.Width, _settings.GameWindow.ClientSize.Height); } var windowRect = new RECT( 0, 0, _settings.WindowSize.Width, _settings.WindowSize.Height); var styles = User32.GetWindowLong(_settings.GameWindow.Hwnd, GetWindowLong.GWL_STYLE); var exStyles = User32.GetWindowLong( _settings.GameWindow.Hwnd, GetWindowLong.GWL_EXSTYLE); var hasMenu = User32.GetMenu(_settings.GameWindow.Hwnd); if (User32.AdjustWindowRectEx(ref windowRect, (uint)styles, hasMenu != IntPtr.Zero, (uint)exStyles)) { _settings.GameWindow.Size = new Rectangle( _settings.GameWindow.Size.X, _settings.GameWindow.Size.Y, windowRect.Right - windowRect.Left, windowRect.Bottom - windowRect.Top); } }
public bool Equals(RECT r) { return r.Left == Left && r.Top == Top && r.Right == Right && r.Bottom == Bottom; }
public static extern bool GetClipCursor(out RECT lpRect);
public static extern bool ClipCursor(ref RECT lpRect);
private static Rectangle CreateRectangle(RECT rect) { return new Rectangle { X = rect.Left, Y = rect.Top, Width = rect.Right - rect.Left, Height = rect.Bottom - rect.Top }; }