Does getClientRect return scaled dimensions?

I call GetClientRectthrough pinvoke in C # to get the dimensions of the panel (in WindowsForm), which I use as the DirectX rendering target area. I would think that WinAPI gives me unscaled (i.e., the return values ​​should be the same regardless of the DPI display options in Windows), but it seems to give me scaled (at least on Windows 8.1, since I haven't tested it on other OSs).

The property ClientRectanglealso returns the same scale sizes as GetClientRect. This remains unchanged when I changed form AutoScaleModeto none.

Is this expected behavior with GetClientRect? If so, how do I get unscaled measurements?

EDIT: This only applies to Windows 8.1. Tested on Windows 7, and GetClientRect returns unscaled dimensions!

+4
source share
1 answer

There are no benefits to P / Invoking GetClientRect. You get exactly the same by requesting a property ClientRectangle.

And yes, either one of them is going to return the size of the client area to physical pixels, which, apparently, is not what you want.

You are probably looking for a method ID2D1RenderTarget::GetSizethat returns the size of a rendering target in device-independent pixels (DIP).

(, ), - ID2D1Factory::GetDesktopDpi, , DIP.

, Windows 8.1, , DPI. , DPI- , . DPI. , :

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
    <asmv3:application>
        <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
            <dpiAware>True/PM</dpiAware>
        </asmv3:windowsSettings>
    </asmv3:application>
</assembly>

Visual Studio "" β†’ " ". " " .

: DPI-Aware Desktop Win32

+3

All Articles