Control the Load Location of an App

joep

Member
Joined
Sep 1, 2005
Messages
9
Programming Experience
5-10
I am developing a windows app in VS2008 to be used along side ESRI’s ArcMap. Most ArcMap users will have dual monitors and I would like the user to be able to choose which monitor my app is loaded on to.

When I deploy the app using the standard install package, the app will load onto which ever monitor the user places the desktop shortcut. However, when using the ClickOnce method of deployment, the placement of the shortcut does not matter and the app always loads on the primary display monitor.

Is there a way to control where an app is loaded by code or any other method?

Thanks,

JoeP
 
Assuming the form's StartPosition is set to Manual, the following code will always display the form on the second monitor if there is one:
VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, _
                       ByVal e As System.EventArgs) Handles MyBase.Load
    If Screen.AllScreens.Length = 1 Then
        'Single screen.
        Me.Location = Point.Empty
    Else
        'Multiple screens, use the second.
        Me.Location = Screen.AllScreens(1).WorkingArea.Location
    End If
End Sub
I imagine you can adapt something from that. You might also save the last position of the form to My.Settings when you exit and use that the next time you startup.
 
Back
Top