Forms and screens

G

Geoff

How can I make sure the edges of a form never go beyond the edge of the screen.
This permits the form edges to be hidden until the mousebutton is released.

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If Userform.Left < 0 then Userform.Left = 0
If Userform.Top < 0 then Userform.Top = 0
End Sub

T.I.A.
Geoff
 
R

RB Smissaert

Private Sub UserForm_Layout()
If UserForm.Left < 0 Then UserForm.Left = 0
If UserForm.Top < 0 Then UserForm.Top = 0
End Sub

Will need a bit more work to deal with the bottom and right edge of the
screen.

RBS
 
G

Geoff

Thank you.
I can calculate the right and bottom edges ok converting screen pixels to
points etc. It was the Layout event I was unaware of.

Geoff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top