Maximize a form to all monitors?
Hello again, I have an application that I'm working on however I'm having one problem. When they click a button it opens a second form which they can use to screen select an area. The only problem is this is only good for one monitor because that's all it can maximize it to.
So what I'm asking is: is there a way to maximize a form to all monitors that a computer may have? Say I have two monitors that are both different resolutions. Is it possible to maximize this form to fit both of these monitors?
Thanks for any help! This is driving me nuts. I doubt this is possible but any help would be nice.
Re: Maximize a form to all monitors?
No you can't do that. What you need to do is to open a new version of your form on each screen.
Code:
For Each scr As Screen In Screen.AllScreens
Dim frm As New Form2
frm.Location = scr.Bounds.Location
frm.WindowState = FormWindowState.Maximized
frm.Show()
Next
Of course you now need to add some code that closes each instance of the form when one of them is closed.
Re: Maximize a form to all monitors?
Ah okay that works well. However, now I have to ask I'm kind of a noob, how would I close the rest of the forms when that one is done. Once the operation finishes what it's doing it closes that one however the one on the second monitor stays open like you said. Any help would be much appreciated.
Re: Maximize a form to all monitors?
Something like this:
Code:
'We can't use a For Each loop here since we close Forms inside
'the loop which changes the OpenForms collection and we can't change
'the collection we're enumerating. So instead we use a regular For loop
'and loop backwards (since when a Form closes the index of the other Forms
' in the collection also changes).
For i As Integer = Application.OpenForms.Count - 1 To 0 Step -1
'Change Form2 on the next line to the class name of your Form
If TypeOf (Application.OpenForms(i)) Is Form2 Then
Application.OpenForms(i).Close()
End If
Next
Re: Maximize a form to all monitors?
Quote:
Originally Posted by
Joacim Andersson
Something like this:
Code:
'We can't use a For Each loop here since we close Forms inside
'the loop which changes the OpenForms collection and we can't change
'the collection we're enumerating. So instead we use a regular For loop
'and loop backwards (since when a Form closes the index of the other Forms
' in the collection also changes).
For i As Integer = Application.OpenForms.Count - 1 To 0 Step -1
'Change Form2 on the next line to the class name of your Form
If TypeOf (Application.OpenForms(i)) Is Form2 Then
Application.OpenForms(i).Close()
End If
Next
This works, however if I put it after the "Next" from when it launches the form but it closes both of the forms from each monitor before you can do what they were made for.
How can I make it so that it doesn't close the remaining forms until the one has been used? :S
Re: Maximize a form to all monitors?
Nevermind, I got it. Duh lol. Thanks for the help! Greatly appreciated!