[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...
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
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.
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?
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. :)