treeview control won't scroll while dragging

Alisa

Registered User.
Local time
Today, 07:23
Joined
Jun 8, 2007
Messages
1,931
I posted this yesterday under "Forms", but after receiveing no responses, it dawned on me this morning that it should have been posted under "Modules", so I deleted the other one and I am reposting it here.

Problem: When dragging an item far on a treeview (out of the current view), the treeview doesn't automatically scroll, forcing the user to drop the item before they get where they are going. Then they have to pick it up and drag it again and again to get to the top (or bottom) of the tree.

Unhelpful gripe about the treeview control: Why the #~!!@)$! doesn't it scroll automatically??!! Who built this s@#*??!!

My attempts at solving this: I found this: http://support.microsoft.com/kb/177743 which explains how to manually scroll the tree while dragging. This seems to be the relevant portion of the example:
Code:
Private Sub Timer1_Timer()
         Set TreeView1.DropHighlight = TreeView1.HitTest(mfX, mfY)
         If m_iScrollDir = -1 Then 'Scroll Up
         ' Send a WM_VSCROLL message 0 is up and 1 is down
           SendMessage TreeView1.hwnd, 277&, 0&, vbNull
         Else 'Scroll Down
           SendMessage TreeView1.hwnd, 277&, 1&, vbNull
         End If
      End Sub
But it isn't directly applicable because the example is for a VB application, not a VBA application in Access. It looks like it is using API calls though, so maybe I could do the same sort of thing in Access, if only I could understand what they are doing.

My question(s): Has anyone successfully implemented anything like this in VBA? Can you share? I don't know anything about VB, can anyone who knows something about VB suggest a way in which the MS KB example could be applied in Access? I don't think this is a RTFM, but if it is, could you kindly direct me towards such manual?

In case it matters:
OS: XP
Access: 2003
Treeview control: version 6.0
 
Well, I have finally figured out the answer to my own question, so I might as well post the solution in case anyone else needs this in the future. I am kind of kicking myself for making it more complicated than it really was, because Microsoft's vb code works basically as-is. The only change I had to make was instead of using a timer "object", which access doesn't have, I just set me.form.timerinterval to 20 at the begining of the start drag event, and back to 0 and the begining of the drop event, and put the Timer1_Timer code in the on timer event of the form. I just copied and paste the rest of the code with no changes and it works.
 
Dragging nodes

Brilliant - just what I was looking for.
 

Users who are viewing this thread

Back
Top Bottom