none
Determining effective display dimensions RRS feed

  • Question

  • My desktop PC has a 1600 x 1200 screen, scaled to 100%.
    My laptop system has 3840 x 2160, but is scaled to 300%; making it effectively 1280 x 720.

    I can access Computer.Screen with Visual Basic to find the height (and width) in pixels, but not the scaling.
    The result is that my VB program thinks the laptop has a much bigger screen.
    How can I find the effective dimensions after scaling?
    Wednesday, June 24, 2020 2:53 AM

Answers

  • After some more tests on both systems, I found  that "scaling" affects the following properties and I don't need to worry about DPI and system calls after all.  :-)
    With a scaling value of 300% enlargement, each of the numbers below is reduced by 1/3:
    Screen.GetBounds(Me): 1280 x 720   (I expected 3840 x 2160)
    Screen.PrimaryScreen.WorkingArea and Screen.GetWorkingArea(Me) are similarly affected.
    • Marked as answer by ronks Thursday, July 2, 2020 3:27 AM
    Thursday, July 2, 2020 3:26 AM

All replies

  • You can use DPI APIs like GetDpiForWindow

    You need a Manifest to get correct results with  :

      <application xmlns="urn:schemas-microsoft-com:asm.v3">
        <windowsSettings>
          <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
          <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitor</dpiAwareness>
         </windowsSettings>
      </application>

    I get :

    96 for 100% 
    120 for 125%
    144 for 150%
    etc...

    Wednesday, June 24, 2020 5:54 AM
  • Thanks! I'll take a look at it.
    Wednesday, June 24, 2020 4:32 PM
  • Hi ronks,

    Did you solve your problem? If your question has been answered then please click the "Mark as Answer" Link at the bottom of the correct post(s), so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 2, 2020 2:35 AM
    Moderator
  • After some more tests on both systems, I found  that "scaling" affects the following properties and I don't need to worry about DPI and system calls after all.  :-)
    With a scaling value of 300% enlargement, each of the numbers below is reduced by 1/3:
    Screen.GetBounds(Me): 1280 x 720   (I expected 3840 x 2160)
    Screen.PrimaryScreen.WorkingArea and Screen.GetWorkingArea(Me) are similarly affected.
    • Marked as answer by ronks Thursday, July 2, 2020 3:27 AM
    Thursday, July 2, 2020 3:26 AM