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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Brown - identify

    #1

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

    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_Mou seMove(ByVal sender As Object, ByVal e As
    System.Windows. Forms.MouseEven tArgs) Handles PictureMove.Mou seMove


    PixelsToDock = 10

    If e.Button = Windows.Forms.M ouseButtons.Lef t Then


    'Top dock
    '-2 to compensate for apparently incorrect
    Screen.PrimaryS creen.Bounds.To p (window border?)
    If Me.Top >= Screen.PrimaryS creen.Bounds.To p - 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.PrimaryS creen.Bounds.Le ft Then ' free
    floating out of docking area, and docking
    newLeft = (e.X + Me.Left + PictureMove.Lef t) -
    lRelOffsetLeft
    If newLeft < 0 Then newLeft = 0 'e.X may make the
    previously calculated newtop
    Me.Left = newLeft
    ElseIf (e.X + Me.Left + PictureMove.Lef t) - lRelOffsetLeft
    >= PixelsToDock Then ' undock
    newLeft = (e.X + Me.Left + PictureMove.Lef t) -
    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

  • Michael C

    #2
    Re: Need some help with my insane window docking method...

    "Matt Brown - identify" <MatthewBrown@g mail.comwrote in message
    news:1170631211 .240565.130330@ h3g2000cwc.goog legroups.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 :-)


    Comment

    • Matt Brown - identify

      #3
      Re: Need some help with my insane window docking method...

      op... that was wrong.

      Comment

      Working...