Scott Kramer
Scott Kramer

Reputation: 1731

dotnet compact framework 3.5 sp1 detect device resolution

I need to detect the device resolution automatically, right now I have a global var & hardwire the resolution:

Public gDeviceRes As String = "640"
'Public gDeviceRes As String = "320"

then recompile for each device, does anyone have a quick snippit of code for this??

Upvotes: 6

Views: 5129

Answers (2)

Scott Kramer
Scott Kramer

Reputation: 1731

This did exactly what i needed:

  Dim screensize As System.Drawing.Rectangle = Screen.PrimaryScreen.Bounds
  Public gDeviceRes As String = screensize.Height

Upvotes: 3

ctacke
ctacke

Reputation: 67168

Depending on your exact needs, you can check the current screen dimensions with Screen.PrimaryScreen or you can P/Invoke GetSystemMetrics with SM_CXSCREEN or GetDeviceCaps with HORZRES. Vertical dimesions are similarly available.

Upvotes: 5

Related Questions