Detecting form going off edge of screen

  • Thread starter Thread starter copyco
  • Start date Start date
C

copyco

Does anyone have any suggestions on this? I have a form that can be
collapsed into a compact size and expanded back to full size. If the
user moves the compact size of the form close to the edge, then when it
is brought to full size, the right edge goes off the edge of the screen.
How can I code to adjust for this? If I code for checking for the
left edge and the size and being a certain distance from the right edge
of the screen, then it will only work for my current screen settings.
What if another user has different screen settings? Would I need to
have code to check the screen settings, or is there a better way to do
this? Thanks.
 
You can get the screen size from the Screen object and develop a general
formula for setting the left and top of your form when is is resized in the
onsizechange event.
 
Wow. I did not know there was a Screen object. Thanks, I got it.

If Me.Left + Me.Width > Screen.PrimaryScreen.Bounds.Right() Then
Me.Left = Screen.PrimaryScreen.Bounds.Right - Me.Width
End If
 
Back
Top