|
-
Dec 5th, 2007, 12:45 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Getting the screen area in VB.Net
Our users like to have their forms open up in the same place each time they use them (i.e. so that they open up in the position they were in when they were previously closed), so we store the location of each form when they close it, and re-apply that location each time they open it. Easy.
However, we have a problem with some users who sometimes use one monitor, and sometimes use two - there have been instances where they closed a form while it was on their second (right-hand) monitor and then try to open it on a laptop with only one screen... and it sticks the form out of sight to the right.
I can get around this easily on the VB6 forms by using:
SystemParametersInfo(SPI_GETWORKAREA, vbNull, pRect, 0)
... to determine how big the screen they're currently using is, and overriding their settings if it would otherwise mean the form being out of sight. However, I can't get it to work in VB.Net - the RECT structure always returns 0 for all positions. So, does anyone know how to get the screen size using VB.Net?
Thanks...
Last edited by InvisibleDuncan; Dec 6th, 2007 at 04:09 AM.
Reason: Resolved
-
Dec 5th, 2007, 01:07 PM
#2
Re: Getting the screen area in VB.Net
If you are using VS 2005 check out: My.Computer.Screen. .....
it has access to methods like GetWorkingArea etc...
It might be what you are looking for
-
Dec 5th, 2007, 01:08 PM
#3
Re: Getting the screen area in VB.Net
check out the Windows.Forms.Screen class. I think you'll find it has the functionality you're looking for.
 I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Dec 5th, 2007, 01:10 PM
#4
Re: Getting the screen area in VB.Net
Hey Ducan, long time no see. 
You can return the screen dimension in .NET with this
Code:
Dim intScrWidth As Integer = Screen.PrimaryScreen.Bounds.Width
Dim intScrHeight As Integer = Screen.PrimaryScreen.Bounds.Height
Does this help?
-
Dec 6th, 2007, 04:08 AM
#5
Thread Starter
Fanatic Member
Re: Getting the screen area in VB.Net
Hi, Hack! It certainly has been a while - I've been working on VB6 a lot lately, so I don't often need help...
I don't have 2005 (we're a bit behind the times here!), but I'll certainly bear Stimbo's solution in mind for when we finally move on. As it was, Hack's post gave me exactly what I wanted.
Thanks to all concerned - much appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|