Hi All,

I have the following code to autoscroll a treeview while I am dragging an item. It works great. The problem is when I have the mouse in the areas where the autoscroll can take place and I don't select a place to drop the dragged item, the timer keeps running and the tree keeps scrolling even though I have stopped the dragging. How can I stop this.

Code:
Private Sub trvTree_OLEDragOver(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, State As Integer)
'Dim nodNode As Node
Dim target As Node
Dim highlight As Boolean

On Error GoTo errh

    '// set the effect
    Effect = vbDropEffectMove
    '// get the node that the object is being dragged over
    Set target = trvTree.HitTest(x, y)
    mfX = x
    mfY = y
    If y > 0 And y < 100 Then 'scroll up
        m_iScrollDir = -1
        Timer2.Enabled = True
    ElseIf y > (trvTree.Height - 200) And y < trvTree.Height Then
        'scroll down
          m_iScrollDir = 1
          Timer2.Enabled = True
    Else
          Timer2.Enabled = False
    End If

    
    
    If target Is TargetNode Then Exit Sub

    Set TargetNode = target

    highlight = False
    If Not (TargetNode Is Nothing) And (blnDragging = True) Then
        '// the dragged object is not over a node, invalid drop target
        '// or the object is not from this control.
        If Mid(TargetNode.Key, 1, 1) = "c" Then
            highlight = True
        End If

        If highlight Then
            Set trvTree.DropHighlight = TargetNode
        Else
            Set trvTree.DropHighlight = Nothing
    End If

        Effect = vbDropEffectNone
    End If

Exit Sub

errh:
    errmsg "The following Exception occured : " & ERR.Description & ",  " & ERR.Source & "", "Exception occured in frmItemManager.trvTree_OLEDragOver()"

End Sub
Code:
Private Sub Timer2_Timer()

On Error GoTo errh

         Set trvTree.DropHighlight = trvTree.HitTest(mfX, mfY)
         If m_iScrollDir = -1 Then 'Scroll Up
         ' Send a WM_VSCROLL message 0 is up and 1 is down
           SendMessage trvTree.hWnd, 277&, 0&, vbNull
         Else 'Scroll Down
           SendMessage trvTree.hWnd, 277&, 1&, vbNull
         End If

Exit Sub
    
errh:
    errmsg "The following Exception occured : " & ERR.Description & ",  " & ERR.Source & "", "Exception occured in frmItemManager.Timer2_Timer()"

End Sub