Scrolling Treeview

T

TexKiernan

Could any one help me figure out how to make my treeview control
(tvwReviewers) to scroll when I drag an item near the bottom of the control?
I have tried many of the samples on the web and can't seem to convert them
just right.
 
T

TexKiernan

Tried that sample already and can't figure out how to change it to work with
my form.
 
T

TexKiernan

does that mean I need to remove the drag and drop event from the form? It
does some data updating and email functions.
 
T

TexKiernan

Still lost... There are a lot of thing going on in there that I don't get.
Do I insert my controls name in the clsTreeViewEnh for motv? I don't see
where the clsTreeViewEnh is instantiated.
 
A

Alex Dybenko

Look at Form_Load event. First you fill your treeview, then you "attach"
form and TV:
Set oTVE.SetForm = Me
Set oTVE.SetTreeVewControl = Me.axProducts

Then you have to define d'n'd definition, as I call it, what kind of node
you can drag, and on what kind of node you can drop it:

Set otved = New clsTreeViewEnhDefinition
Set otved.rst = rstProduct
otved.strNodeType = "p"
otved.strNodeToDrop = "s"
otved.strIDField = "ProductID"
otved.strParentIDField = "SupplierID"
oTVE.AddDefinition otved

but this one depends on my method filling TV, if you have a different one -
then you have to adjust the code.

Just go through the code to find out how it works, nothing complicated there


--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 
T

TexKiernan

Still can't make it work. Too may different references to too many different
functions that I'm not using. It is difficult to translate all the names
used to refer to the control and weed out the functions that I'm not using.
My control is already filled, and all my children are drag-able. If I
understand the function correctly, I need to define the location of the top
and bottom of the control then "sendmessage" to window when the hittest is
within a specified range of the top or bottom of the control? Here is the
code to Drag and Drop function:

Private Sub tvwReviewers_OLEDragOver(Data As Object, Effect As Long, _
Button As Integer, Shift As
Integer, _
x As Single, y As Single, State
As Integer)
Dim oTree As Treeview
Dim pnod As Node
' Create a reference to the TreeView control.
Set oTree = Me.tvwReviewers.Object
' If no node is selected, select the first node you dragged over.
If oTree.SelectedItem Is Nothing Then
Set oTree.SelectedItem = oTree.HitTest(x, y)
End If
' Highlight the node being dragged over as a potential drop target.
Set oTree.DropHighlight = oTree.HitTest(x, y)
End Sub
 
A

Alex Dybenko

you have to add this code:
mfX = x
mfY = y
'Scroll treeview
If y > 0 And y < 400 Then 'scroll up
' Send a WM_VSCROLL message 0 is up and 1 is down
m_iScrollDir = -1
ElseIf y > (mctlTV.Height - 500) And y < mctlTV.Height Then
'scroll down
m_iScrollDir = 1
Else
m_iScrollDir = 0
End If

and then this code to timer event:
'Scroll TV if neccesary
Set moTV.DropHighlight = moTV.HitTest(mfX, mfY)
If m_iScrollDir = -1 Then 'Scroll Up
' Send a WM_VSCROLL message 0 is up and 1 is down
SendMessage moTV.hWnd, 277&, 0&, vbNull
ElseIf m_iScrollDir = 1 Then 'Scroll Down
SendMessage moTV.hWnd, 277&, 1&, vbNull
End If


--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 
T

TexKiernan

GOT IT!!!! Thanks!!!!!!!!!!! I've been having nightmares about that! Thank
you so much!
 

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