@boiler, Thank you for the feedback. I would argue that, if a variable
y is affected by another variable
x, then when
x changes
y changes as well. As written, the documentation implies that the values of
A_GuiWidth and
A_GuiHeight change with changes in the DPI scaling factor. That's not my observation. My understanding is that the actual size of the Gui client area is affected by the DPI scaling factor but that
A_GuiWidth and
A_GuiHeight, because they are normalized variables (by dividing by the DPI scaling factor), are not. I would agree that the DPI scaling factor is
used in the calculation of
A_GuiWidth and
A_GuiHeight but doesn't mean that the value of those variables are affected by it.
Below is a script to test this point.
Code: Select all
#NoEnv
DPIScaling := true
Gui, % (DPIScaling ? "" : "-DPIScale ") "+Resize +LastFound"
Gui Show, w500 h500
GetClientRect(WinExist(), W, H)
return
GuiSize:
MsgBox % (DPIScaling ? "Screen DPI: " A_ScreenDPI : "DPI scaling disabled.") "`nActual size of client area: " W " x " H "`nNormalized size of client area: " A_GuiWidth " x " A_GuiHeight
return
Esc::
GuiClose:
GuiEscape:
ExitApp
GetClientRect(hwnd, ByRef W, ByRef H) {
VarSetCapacity(RECT, 16)
if DllCall("GetClientRect", "Ptr", hwnd, "Ptr", &RECT, "Int")
W := NumGet(RECT, 8, "Int"), H := NumGet(RECT, 12, "Int")
}
Here are results of several tests:
Code: Select all
| -DPIScale | +DPIScale
-------------------------------------------------------------------------------------------------
A_ScreenDPI | Width Height A_GuiWidth A_GuiHeight | Width Height A_GuiWidth A_GuiHeight
-------------------------------------------------------------------------------------------------
96 (100%) | 500 500 500 500 | 500 500 500 500
168 (175%) | 500 500 500 500 | 875 875 500 500
192 (200%) | 500 500 500 500 | 1000 1000 500 500
288 (300%) | 500 500 500 500 | 1500 1500 500 500
As can be seen from the above numbers, the values of
A_GuiWidth and
A_GuiHeight are invariant with the DPI scaling factor.
EDIT: Corrected miscalculation. Thank you
@boiler.