Maximizing the app on the second monitor.

  • Thread starter Thread starter Frank Rizzo
  • Start date Start date
F

Frank Rizzo

Hello,

I am trying to make sure that my app always loads on the monitor (and
maximizes there).
Currently, I just get the .Bounds off Screen.AllScreens[1].

Then I change the .Location of my winform to the .Bounds.Left and
..Bounds.Top and then I maximize the form.

Is there a better way of doing this, as this approach seems like a bit
of a hack.

Thanks
 
Frank,
I normally set the bounds of my form to the bounds of the screen.

Something like (VB.NET):

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
Dim s As Screen
For Each s In Screen.AllScreens
If Not s.Primary Then Exit For
Next
Me.Bounds = s.Bounds
Me.WindowState = FormWindowState.Maximized
End Sub

NOTE: I look for the non primary screen, rather then assume AllScreens[1] is
the second screen...

Hope this helps
Jay

| Hello,
|
| I am trying to make sure that my app always loads on the monitor (and
| maximizes there).
| Currently, I just get the .Bounds off Screen.AllScreens[1].
|
| Then I change the .Location of my winform to the .Bounds.Left and
| .Bounds.Top and then I maximize the form.
|
| Is there a better way of doing this, as this approach seems like a bit
| of a hack.
|
| Thanks
 
Back
Top