I am attempting to restrict movement of an mdi child window to the bounds of its parent. This is how I am doing it now...
This works, but it seems that the mouse keeps trying to move it as it goes past the bounds. As I attempt to drag it further past the bounds, it seems to be drawing one frame at the bad position before calling the me.move event.
A. Is there a way to trap the movement before the form is drawn?
B. Am I an idiot, and is there some freaking easy way to do this that I am missing?
(Probably B)
VB.NET:
Private Sub frmUpdateTime_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
If Me.Left < 0 Then Me.Left = 0
If Me.Top < 0 Then Me.Top = 0
If Me.Left > Me.Parent.ClientSize.Width - Me.Width Then Me.Left = Me.Parent.ClientSize.Width - Me.Width
If Me.Top > Me.Parent.ClientSize.Height - Me.Height Then Me.Top = Me.Parent.ClientSize.Height - Me.Height
End Sub
This works, but it seems that the mouse keeps trying to move it as it goes past the bounds. As I attempt to drag it further past the bounds, it seems to be drawing one frame at the bad position before calling the me.move event.
A. Is there a way to trap the movement before the form is drawn?
B. Am I an idiot, and is there some freaking easy way to do this that I am missing?
(Probably B)