private void timer1_Tick(object sender, EventArgs e) { try { var winInfo = new Windowinfo(); GetWindowInfo(_gameHandle, ref winInfo); _r = winInfo.rcWindow; _r.Left += (int)winInfo.cxWindowBorders / 2; _r.Top += (int)winInfo.cyWindowBorders; if (string.Compare(Dec2HexL(winInfo.dwStyle)[2].ToString(), "C", StringComparison.Ordinal) == 0) { _r.Top += Dc; } if (OsuSizeX != SystemInformation.PrimaryMonitorSize.Width | OsuSizeY != SystemInformation.PrimaryMonitorSize.Height) { OsuCoordX = _r.Left; OsuCoordY = _r.Top + 6; } else { OsuCoordX = 0; OsuCoordY = 12; } var swidth = OsuSizeX; var sheight = OsuSizeY; if (swidth * 3 > sheight * 4) { swidth = sheight * 4 / 3; } else { sheight = swidth * 3 / 4; } XMultiplier = swidth / 640f; YMultiplier = sheight / 480f; XOffset = (int)(OsuSizeX - 512 * XMultiplier) / 2; YOffset = (int)(OsuSizeY - 384 * YMultiplier) / 2; } catch { // ignored } }
protected override void OnPaint(PaintEventArgs e) { var info = new Windowinfo(); info.cbSize = (uint)Marshal.SizeOf(info); var activeWindowHandle = NativeMethods.GetForegroundWindow(); NativeMethods.GetWindowInfo(activeWindowHandle, ref info); if (FHandle != activeWindowHandle) { Width = info.rcWindow.Right - info.rcWindow.Left; Height = info.rcWindow.Bottom - info.rcWindow.Top; } DwmExtendFrameIntoClientArea(Handle, ref _marg); base.OnPaint(e); }
internal static extern bool GetWindowInfo(IntPtr hwnd, ref Windowinfo pwi);
private void timer1_Tick(object sender, EventArgs e) { try { var winInfo = new Windowinfo(); GetWindowInfo(_gameHandle, ref winInfo); _r = winInfo.rcWindow; _r.Left += (int) winInfo.cxWindowBorders / 2; _r.Top += (int) winInfo.cyWindowBorders; if (string.Compare(Dec2HexL(winInfo.dwStyle)[2].ToString(), "C", StringComparison.Ordinal) == 0) _r.Top += Dc; if (OsuSizeX != SystemInformation.PrimaryMonitorSize.Width | OsuSizeY != SystemInformation.PrimaryMonitorSize.Height) { OsuCoordX = _r.Left; OsuCoordY = _r.Top + 6; } else { OsuCoordX = 0; OsuCoordY = 12; } var swidth = OsuSizeX; var sheight = OsuSizeY; if (swidth * 3 > sheight * 4) swidth = sheight * 4 / 3; else sheight = swidth * 3 / 4; XMultiplier = swidth / 640f; YMultiplier = sheight / 480f; XOffset = (int) (OsuSizeX - 512 * XMultiplier) / 2; YOffset = (int) (OsuSizeY - 384 * YMultiplier) / 2; } catch { // ignored } }
private static extern bool GetWindowInfo(IntPtr hwnd, ref Windowinfo pwi);