How to tell if a form is coming up off the desktop

nanomous
09-10-2003, 10:08 AM
:huh:

I am storing main form locations in the Registry; other forms come up in relation to the main forms. I need to know when a form is coming up either partially or completely off the desktop. I believe I can move it back from there (maybe not with any elegance, but it should work), but it seems there has to be some simple mechanism to tell if they're offscreen.

Any ideas? :confused:

Thankings and blessings on youse :)

Nanomous
The grandmother with brains (although they are currently vacationing someplace sunny--without me)

zak2zak
09-10-2003, 11:02 AM
May be this helps...
A sample routine

'Top Over
If Me.Top < 0 Then
MsgBox "Over : " & Me.Top
Me.Top = 0
End If
'Right Over
If Me.Left + Me.Width > Screen.Width Then
MsgBox "Over : " & (Me.Left + Me.Width) - Screen.Width
Me.Left = Screen.Width - Me.Width
End If
'Left Over
If Me.Left < 0 Then
MsgBox "Over : " & Me.Left
Me.Left = 0
End If
'Bottom Over
If Me.Top + Me.Height > Screen.Height Then
MsgBox "Over : " & (Me.Top + Me.Height) - Screen.Height
Me.Left = Screen.Height - Me.Height
End If
'To Center A Form
Me.Move (Screen.Width - Me.ScaleWidth) / 2, (Screen.Height - Me.ScaleHeight) / 2

nanomous
09-10-2003, 11:21 AM
You are an angel :)

Thank you!

Nanomous

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum