Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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??

like image 738
Scott Kramer Avatar asked Oct 14 '08 18:10

Scott Kramer


2 Answers

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.

like image 200
ctacke Avatar answered Nov 10 '22 07:11

ctacke


This did exactly what i needed:

  Dim screensize As System.Drawing.Rectangle = Screen.PrimaryScreen.Bounds
  Public gDeviceRes As String = screensize.Height
like image 28
Scott Kramer Avatar answered Nov 10 '22 07:11

Scott Kramer