SetWindowPos and multiple monitors with different resolutions

I have two monitors that work with different resolutions. The left monitor is 1920x1200. The right monitor (main monitor) is 1920x1080.

I want to use SetWindowPos so that the window occupies the entire vertical height of the left hand monitor.

That's what I'm doing:

x = GetSystemMetrics(SM_XVIRTUALSCREEN);
hMonitor = monitorFromPoint(x, 0, MONITOR_DEFAULTTONEAREST);
MONITORINFO moninfo;
moninfo.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(hMonitor, moninfo);

height = moninfo.rcWork.bottom - moninfo.rcWork.top;

SetWindowPos(hwnd, 0, moninfo.rcWork.left, moninfo.rcWord.top, width, height, SWP_NOZORDER | SWP_NOACTIVATE);

I confirmed that the height is calculated to 1200 (expected b / c, which is the vertical resolution of the target monitor).

However, after calling SetWindowPos, the rectangle of the window does not fill the entire height of the screen (it is actually high 1080).

I even tried this in VBA just for a giggle:

Public Sub testSWP()
    Dim hwnd As Long
    hwnd = &H1D2F2C

    SetWindowPos &H1D2F2C, 0, -1900, 0, 150, 1200, SWP_NOZORDER Or SWP_NOACTIVATE
    Dim r As RECT
    GetWindowRect hwnd, r
    ' at this point, r.bottom = 1080
End Sub

This is good and good (the GetWindowRect documentation says that the coordinates will be in the client space, and I assume that win32 translates between the resolution of my primary and secondary monitor.

. , , , - , " "?

+4
2

. , SetWindowPos , . , .

: / ?

+2

( ..) (, YouTube ).

, , , . CreateWindow WS_POPUP (. dwStyle). , .

, , . EnumMonitors , GetMonitorInfo , .

0

Source: https://habr.com/ru/post/1535114/


All Articles