By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,376 Members | 1,581 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,376 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Feb 4 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Matt Brown - identify" <Ma**********@gmail.comwrote in message
news:11**********************@h3g2000cwc.googlegro ups.com...
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 :-)
Feb 5 '07 #2

P: n/a
op... that was wrong.

Feb 5 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.