Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Screen resolution

Status
Not open for further replies.

Westond

Programmer
Joined
Jan 19, 2005
Messages
43
Location
US
I have searched the forms and there are several places that talk about this but I cant get it to work. I just need to know what resolution the user has set. This is what I have found other places but the Screen keeps comming up undeclared?

sArea = "Screen"......

Dim sArea As System.Drawing.Rectangle
sArea = Screen.PrimaryScreen.WorkingArea()

'Bigger than Required?
If sArea.Height >= 768 And sArea.Width > 1024 Then
Me.Size = New Size(1024, 768)
Me.WindowState = FormWindowState.Normal
Me.CenterToScreen()
Else
Me.WindowState = FormWindowState.Maximized
End If

THanks for any help
 
If you are using a Windows App, you should be able to user the Screen namespace. If you are using a console app, you will have to add a reference to System.Windows.Forms.Dll and System.Drawing.Dll and then use:

Code:
Dim x As Integer = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width
Dim Y As Integer = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
What about a web app?
 
1) Ask in the ASP.Net forum. VB.Net apps are windows base.

2) Your code will run server side, so you won't be able to get the client's screen size with ADO.Net

3) As the ASP.Net forum will probrably tell you, ask in the JavaScript forum where this very question is asked weekly, and I beleive may even have a FAQ.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top