Screen.Bounds is not returning correct values

sabahat hassan 21 Reputation points
2022-11-04T15:19:35.257+00:00

I wanted to get the system's resolution and use Screen.bounds in my WinForms App. The code was running pretty well a few weeks before, and it was getting correct values, but somehow for the past few days, it's not returning valid values and always returning 560 X 300, whereas my Resolution is set to 1366 X 768 with 100% scaled! As you can see in the attached images debugging values show the width and height of 556 and 300, respectively, whereas if you see these debugging values in IEnumerable Visualizer, then it shows the correct values (1366 X 768). Can anyone point out the issue, or I'm missing something?

.net Target Framework is 4.6.2 while I'm using Windows 11.
I have tried every possible solution to making the app dpi Aware, and setting the scale to 100%, but nothing has257210-1.jpegworked for me so far! Thanks!

257285-screenbounds.png

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,835 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 81,746 Reputation points
    2022-11-04T15:25:49.583+00:00

    it's not returning valid values and always returning 560 X 300

    It is in hexa from the screen (0x560 and 0x300)

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Viorel 112.5K Reputation points
    2022-11-04T15:32:22.457+00:00

    Right-click the popup-window that displays the Bounds, and select "Hexadecimal Display".

    1 person found this answer helpful.