Share via

"WorkingArea" reporting incorrectly.

Mugsy's RapSheet 216 Reputation points
2023-09-07T12:01:29.94+00:00

I developed an app that first checks the user's screen size on startup to see if it's big enough.

A user with a 4K monitor says he's being told his screen isn't big enough. He must run at a LOWER rez to get the program to run.

My detection code:

Dim intWorkingWidth As Integer = Screen.PrimaryScreen.WorkingArea.Width
If intWorkingWidth < 1366 Then
   MsgBox("This program requires a minimum resolution of 1366x768.", MsgBoxStyle.Information, "Resolution Alert")
   End
End If

I tested the app at 4K on my own computer and have no problem. Why might his "WorkingArea" be reporting as < 1366? Is there a better way to check screen size?

TIA

Developer technologies | VB
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other

A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.


3 answers

Sort by: Most helpful
  1. Mugsy's RapSheet 216 Reputation points
    2023-09-08T16:09:30.6666667+00:00

    Follow-up:

    User had scaling set to 300%. SMH :)

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. Castorix31 91,876 Reputation points
    2023-09-08T18:33:38.45+00:00

    To get the right resolution even if DPI changes, you can add a Manifest file, 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>
    

    or use the method from MSDN :

    https://learn.microsoft.com/en-us/dotnet/desktop/winforms/high-dpi-support-in-windows-forms?view=netframeworkdesktop-4.8

    Was this answer helpful?


  3. Dewayne Basnett 1,386 Reputation points
    2023-09-07T15:39:47.5133333+00:00

    If the monitor is 4K it is hard to believe that the width is less than 1366.

    This might help figure it out. (fwiw - I did notice when looking at my 4K monitor that clicking the resolution dropdown placed 1366 x 768 under the cursor)

            Dim intWorkingWidth As Integer = Screen.PrimaryScreen.WorkingArea.Width
            If intWorkingWidth < 1366 Then 'what happens if you change the check to <=
                Dim s As String
                s = String.Format("This program requires a minimum resolution of 1366 × 768. Your monitor W: {0} × H: {1}",
                                   Screen.PrimaryScreen.WorkingArea.Width,
                                   Screen.PrimaryScreen.WorkingArea.Height)
    
                MessageBox.Show(s, "Resolution Alert", MessageBoxButtons.OK, MessageBoxIcon.Information)
                'don't use End
            End If
    
    

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.