Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop a form moving too far?

Status
Not open for further replies.

99mel

Programmer
Oct 18, 1999
379
GB
Hi everyone,

Does anyone know if its possible to stop a form being moved (by the user) outside the screens edges?

Thanks for any info!

 
You could hook into the eventQueue and look for the message WM_MOVING (I don't think that VB automatically checks/maps that message, but it is there). When this message gets fired, check the forms Top and Left properties and compare them with the screen size and if they are not within the bounds that you have defined, stop the move. - Jeff Marler B-)
 
how do u hook into the EventQueue and look for that message?
:)

Thanks again
 
Okay.. I;m doing this from the head so I hope it works...

Total = Screen.Width / Screen.TwipsPerPixelX
Tot = Screen.Height / Screen.TwipsPerPixelY

If form1.left = < 0 or form1.left > (total - form1.width) then
'out of screen put code here
end if

if form1.top = < 0 or form1.left > (tot - form1.top) then
'out of screen
end if

Hope this helps...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top