M
Matt Brown - identify
Hello,
I've spent the better part of the day going over code and thinking and
have come up with the following docking method that works perfectly.
At this point, my brain is about to explode and I was wondering if
someone can help me figure out the calculations for right and bottom
docking:
note: lRelOffsetLeft and lRelOffsetTop are calculated on mousedown
(location of mouse in relation to top and left of picturebox)
_______________
Private Sub PictureMove_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureMove.MouseMove
PixelsToDock = 10
If e.Button = Windows.Forms.MouseButtons.Left Then
'Top dock
'-2 to compensate for apparently incorrect
Screen.PrimaryScreen.Bounds.Top (window border?)
If Me.Top >= Screen.PrimaryScreen.Bounds.Top - 2 Then '
free floating out of docking area, and docking
newTop = (e.Y + Me.Top + PictureMove.Top) -
lRelOffsetTop
If newTop < 0 Then newTop = -2 'e.Y may make the
previously calculated newtop < -2
Me.Top = newTop
ElseIf (e.Y + Me.Top + PictureMove.Top) - lRelOffsetTop >=
PixelsToDock Then ' undock
'If newTop < 0 Then newTop = 0
newTop = (e.Y + Me.Top + PictureMove.Top) -
lRelOffsetTop
Me.Top = newTop
End If
'Left dock
If Me.Left >= Screen.PrimaryScreen.Bounds.Left Then ' free
floating out of docking area, and docking
newLeft = (e.X + Me.Left + PictureMove.Left) -
lRelOffsetLeft
If newLeft < 0 Then newLeft = 0 'e.X may make the
previously calculated newtop
Me.Left = newLeft
ElseIf (e.X + Me.Left + PictureMove.Left) - lRelOffsetLeft
lRelOffsetLeft
Me.Left = newLeft
End If
End If
End Sub
__________________
The usual method of adjusting the location properties of a form causes
the form to "shake."
This does not do that. So if someone can help me figure out the
bottom and right calculations, we may have gold here.
Thanks!
Matt
I've spent the better part of the day going over code and thinking and
have come up with the following docking method that works perfectly.
At this point, my brain is about to explode and I was wondering if
someone can help me figure out the calculations for right and bottom
docking:
note: lRelOffsetLeft and lRelOffsetTop are calculated on mousedown
(location of mouse in relation to top and left of picturebox)
_______________
Private Sub PictureMove_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureMove.MouseMove
PixelsToDock = 10
If e.Button = Windows.Forms.MouseButtons.Left Then
'Top dock
'-2 to compensate for apparently incorrect
Screen.PrimaryScreen.Bounds.Top (window border?)
If Me.Top >= Screen.PrimaryScreen.Bounds.Top - 2 Then '
free floating out of docking area, and docking
newTop = (e.Y + Me.Top + PictureMove.Top) -
lRelOffsetTop
If newTop < 0 Then newTop = -2 'e.Y may make the
previously calculated newtop < -2
Me.Top = newTop
ElseIf (e.Y + Me.Top + PictureMove.Top) - lRelOffsetTop >=
PixelsToDock Then ' undock
'If newTop < 0 Then newTop = 0
newTop = (e.Y + Me.Top + PictureMove.Top) -
lRelOffsetTop
Me.Top = newTop
End If
'Left dock
If Me.Left >= Screen.PrimaryScreen.Bounds.Left Then ' free
floating out of docking area, and docking
newLeft = (e.X + Me.Left + PictureMove.Left) -
lRelOffsetLeft
If newLeft < 0 Then newLeft = 0 'e.X may make the
previously calculated newtop
Me.Left = newLeft
ElseIf (e.X + Me.Left + PictureMove.Left) - lRelOffsetLeft
newLeft = (e.X + Me.Left + PictureMove.Left) -= PixelsToDock Then ' undock
lRelOffsetLeft
Me.Left = newLeft
End If
End If
End Sub
__________________
The usual method of adjusting the location properties of a form causes
the form to "shake."
This does not do that. So if someone can help me figure out the
bottom and right calculations, we may have gold here.
Thanks!
Matt