Library code snippets
Screen Resolution
By Bharat Nagarajan, published on 05 Sep 2003
This code snippet will allow you to fetch the screen resolution. Put the code in the button named btnResol and see.
Private Sub btnResol_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnResol.Click
MessageBox.Show (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width())
MessageBox.Show (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height())
End
Sub
Related articles
Related discussion
-
Error in VB code
by glib162002 (0 replies)
-
i have struck with my project in vb.net
by gangireddysaritha (1 replies)
-
Very slow inserts using SqlCommand.ExecuteNonQuery()
by porchelvi (1 replies)
-
Datagridview Setting datasource property of datagridviewcomboboxcell at run time
by sairfan1 (2 replies)
-
vb.net mp3 +g player
by novavb6 (1 replies)
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum)
Events coming up
-
Dec
6
Developing AJAX Web Applications with Castle Monorail
London, United Kingdom
Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!
Hi! Fortius
I too have same problem of "workingarea.height" showing less 28 pixels. This due to the Task Bar. If u hide it and access the "workingarea.height" then it shows 600 pixels (for screen resolution 800 x 600).
Also if u try this code the Bound property of Screen will fetch you the exact pixels irrespective of Taskbar state.
' Code from MSDN
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim Index As Integer
Dim UpperBound As Integer
' Gets an array of all the screens connected to the system.
Dim Screens() As System.Windows.Forms.Screen = _
System.Windows.Forms.Screen.AllScreens
UpperBound = Screens.GetUpperBound(0)
For Index = 0 To UpperBound
' For each screen, add the screen properties to a list box.
ListBox1.Items.Add("Device Name: " + Screens(Index).DeviceName)
ListBox1.Items.Add("Bounds: " + Screens(Index).Bounds.ToString())
ListBox1.Items.Add("Type: " + Screens(Index).GetType().ToString())
ListBox1.Items.Add("Working Area: " + Screens(Index).WorkingArea.ToString())
ListBox1.Items.Add("Primary Screen: " + Screens(Index).Primary.ToString())
Next
End Sub
hey, this code isn't working prefectly (at least not at my side) ... the height returned by "workingarea.height" is always 28 pixels less than the original resolution for e.g. 800 X 600 is returned as 800 X 572 - 1024 X 768 is returned as 1024 X 740 .... anyways i found the work around .. instead of using WorkingArea.XX methods use "Bounds" method to get the exact figure.
Dim xBounds As Rectangle = System.Windows.Forms.Screen.PrimaryScreen.Bounds
Label1.Text = xBounds.Width & " X " & xBounds.Height
plus if anybody knows how to change the screen resolution pls. reply me, i would be highly g8ful.
Regards,
Fortius.
This thread is for discussions of Screen Resolution.