scroll treeview list when drag and drop

I

iccsi

I have a tree view list on the fom and set scroll to yes.
The vertical scroll bar shows and works only when click on the
vertical bar.

It does not scroll when I tried to drap and drop a node out of
current list.

Is it possible to have tree view list scroll when drag and drop the
notes?

Your information is great appreciated,
 
I

inungh

Yes it is.  You first must use

Public Declare Function SendMessageLong _
 Lib "user32" Alias "SendMessageA" _
 (ByVal hWnd As Long, ByVal wMsg As Long, _
 ByVal wParam As Long, lParam As Long) As Long

put that it in public variable or api call class

also place in the forms timer event
Private Sub Form_Timer()
Set trvw.DropHighlight = trvw.HitTest(mfX, mfY)
If Scrollup Then
    SendMessageLong trvw.hWnd, 277&, 0&, vbNull
Else
    SendMessageLong trvw.hWnd, 277&, 1&, vbNull
End If
End Sub

declare at module level
Private mfX As Single
Private mfY As Single
Private WithEvents trvw As TreeView
Private Scrollup As Boolean

you will also need to test the drag over event
Private Sub TrVw_OLEDragOver(Data As MSComctlLib.DataObject, Effect As Long,
Button As Integer, Shift As Integer, x As Single, y As Single, STATE As
Integer)
On Error GoTo HandleErr

If indrag = True Then
    Set trvw.DropHighlight = trvw.HitTest(x, y)
    mfX = x
    mfY = y
    If y > 0 And y < 100 Then 'scroll up
      Scrollup = True
      Me.TimerInterval = 100
    ElseIf y > (Me.TreeView8.Height - 200) And y < Me.TreeView8.Height Then
      Scrollup = False
      Me.TimerInterval = 100
    Else
      Me.TimerInterval = 100
    End If
End If

exithere:
    Exit Sub
HandleErr:
    If QueueError(Err) Then GoTo exithere: On Error GoTo 0: Resume

End Sub

Thanks millions,
 

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