Rectangle Marker

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dominic Vella

    Rectangle Marker

    I'm trying to make a rectangle follow my mouse along the X axis.

    For some reason, the rectangle toggle between two places on my form, both
    somewhat proportional from where I first click, but neither in line with the
    mouse pointer. It's as if at:
    * one pixel X=how far the mouse has moved from the point it clicked, the
    * next pixel X=current X position minus how far the mouse has moved.

    Here's my code.

    Private Sub rctMarker_Mouse Move(Button As Integer, Shift As Integer, X As
    Single, Y As Single)
    If (Button And acLeftButton) 0 Then
    rctMarker.Left = X
    End If
    End Sub

    Am I doing this correctly, or am I supposed to reference to the forms X
    reference?


    Thanks in advance.


    Dom


  • DFS

    #2
    Re: Rectangle Marker

    Dominic Vella wrote:
    I'm trying to make a rectangle follow my mouse along the X axis.
    >
    For some reason, the rectangle toggle between two places on my form,
    both somewhat proportional from where I first click, but neither in
    line with the mouse pointer. It's as if at:
    * one pixel X=how far the mouse has moved from the point it clicked,
    the * next pixel X=current X position minus how far the mouse has moved.
    >
    Here's my code.
    >
    Private Sub rctMarker_Mouse Move(Button As Integer, Shift As Integer,
    X As Single, Y As Single)
    If (Button And acLeftButton) 0 Then
    rctMarker.Left = X
    End If
    End Sub
    >
    Am I doing this correctly, or am I supposed to reference to the forms
    X reference?

    This should center the rectangle on your mouse, and move it as you want:

    rctMarker.Left = rctMarker.Left + X - (0.5 * rctMarker.Width )


    Comment

    • Dominic Vella

      #3
      Re: Rectangle Marker

      Ohhh, I'm supposed to re-reference to my rctMarker.Left. How interesting.

      Thanks.


      Dom

      "DFS" <nospam@dfs_.co mwrote in message
      news:g9mDj.2153 3$vr3.8490@bign ews2.bellsouth. net...
      Dominic Vella wrote:
      >I'm trying to make a rectangle follow my mouse along the X axis.
      >>
      >For some reason, the rectangle toggle between two places on my form,
      >both somewhat proportional from where I first click, but neither in
      >line with the mouse pointer. It's as if at:
      >* one pixel X=how far the mouse has moved from the point it clicked,
      >the * next pixel X=current X position minus how far the mouse has moved.
      >>
      >Here's my code.
      >>
      >Private Sub rctMarker_Mouse Move(Button As Integer, Shift As Integer,
      >X As Single, Y As Single)
      > If (Button And acLeftButton) 0 Then
      > rctMarker.Left = X
      > End If
      >End Sub
      >>
      >Am I doing this correctly, or am I supposed to reference to the forms
      >X reference?
      >
      >
      This should center the rectangle on your mouse, and move it as you want:
      >
      rctMarker.Left = rctMarker.Left + X - (0.5 * rctMarker.Width )
      >
      >

      Comment

      Working...