Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Make a form open to the right hand side of the user's monitor

Is there a way to make a form open to the right hand side of the user's monitor?  Or do they have to manually move it every time they open it?
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

You would do something like this:

Declare Function GetSystemMetrics32 Lib "user32" _
    Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long

Private Sub Form_Open(Cancel As Integer)    
    MonitorW = GetSystemMetrics32(0) * 1440 / 96
    MonitorH = GetSystemMetrics32(1) * 1440 / 96
    
    Me.Move 600, 600, MonitorW - 1200, MonitorH - 2000
End Sub

Open in new window


  Using the Move to place the form where you wanted.

Jim.
Avatar of SteveL13

ASKER

Jim,  I don't seem to be able to make this work.  I copy/pasted this in a public module:


Declare Function GetSystemMetrics32 Lib "user32" _
    Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long

Open in new window


And pasted this in the onopen event of the form:

Private Sub Form_Open(Cancel As Integer)    
    MonitorW = GetSystemMetrics32(0) * 1440 / 96
    MonitorH = GetSystemMetrics32(1) * 1440 / 96
    
    Me.Move 600, 600, MonitorW - 1200, MonitorH - 2000
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial