Need some help with my insane window docking method...

  • Thread starter Matt Brown - identify
  • Start date
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
= PixelsToDock Then ' undock
newLeft = (e.X + Me.Left + PictureMove.Left) -
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
 
M

Michael C

Matt Brown - identify said:
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)

This sounds too much like you're wanting someone to do the work for you. I
can wade through the page and a bit of code you posted if you like but
you'll need to be paying me :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top