X-Y Coordinates of node on Treeview without using mouse click/ Keystrokes

How can I find the X-Y Co-ordinates
of a particular node on a treeview without using mouse click/ Keystrokes?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There is no direct way of doing this, but you could use the HitTest procedure in conjunction with e.g. a binary search routine?
SelesAuthor Commented:
Thanks. I know there's no direct way to doing that.

I want to raise what API Procedures may help to solve.

My Goal is setting a function to find
X-Y Client Coordinates of a node in the Treeview window by providing the Key of that node at any time.
' add treeview, paste this code
Option Explicit
Private Const TV_FIRST = &H1100
Private Const TVM_GETITEMRECT = (TV_FIRST + 4)
Private Const TVM_GETNEXTITEM = (TV_FIRST + 10)
Private Type RECT
  Left As Long
  Top As Long
  Right As Long
  Bottom As Long
End Type
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Sub Form_Click()
    Dim ret As Long, rc As RECT, hitem As Long
    ' GetTVItemFromNode function is complex
    '    see: 'Treeview node <-> item handle demo'
    '    http://www.mvps.org/btmtz/treeview/
    'hitem = GetTVItemFromNode(TreeView1.hwnd, TreeView1.Nodes(Key))
    ' root is simple :)
    hitem = SendMessage(TreeView1.hwnd, TVM_GETNEXTITEM, ByVal 0&, ByVal 0&)
    rc.Left = hitem
    ret = SendMessage(TreeView1.hwnd, TVM_GETITEMRECT, 1&, rc)
    MsgBox rc.Left & " " & rc.Right & " " & rc.Top & " " & rc.Bottom
End Sub

Private Sub Form_Load()
    Dim Node1 As Node, i As Integer, j As Integer
    ' fill treeview
    With TreeView1
        For i = 1 To 3
            Set Node1 = .Nodes.Add(, , "Root" & i, "Root" & i)
            For j = 1 To 3
                .Nodes.Add Node1.Index, tvwChild, "Root" & i & "Child" & j, _
                    "Root" & i & "Child" & j
            Node1.Expanded = True
    End With
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SelesAuthor Commented:
Thank You.
It helps me a lot.
Thanks for your points.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.