-
Is thre a way of telling if your usercontrol has been moved at design time. Something like the resize event but for moving the control rather than resizing it, or are there any other ways of doing it.
I'm very wary about subclassing user controls at design time because that's almost a garrenteed way of freezing your machine. Does anyone know another method of doing this without having a timer keep checking it's position.
-
If you're talking about desing time only then you can do something like this. Put this code into the UserControl:
Code:
Private intLeft As Integer
Private intTop As Integer
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Sub UserControl_ControlMove(ByVal pOldLeft As Integer, ByVal pOldTop As Integer, ByVal pNewLeft As Integer, ByVal pOldTop As Integer)
'Do your things here to handle Control Move
End Sub
Private Sub Timer1_Timer()
Dim rec As RECT
Call GetWindowRect(UserControl.hwnd, rec)
If intTop <> rec.Top Or intLeft <> rec.Left Then
UserControl_ControlMove intLeft, intTop, rec.Left, rec.Top
intTop = rec.Top
intLeft = rec.Left
End If
End Sub
Private Sub UserControl_Show()
Dim rec As RECT
Call GetWindowRect(UserControl.hwnd, rec)
intTop = rec.Top
intLeft = rec.Left
Timer1.Interval = 50
End Sub
This way the procedure UserControl_ControlMove will fire if the control changed it's location.