Option Explicit
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
Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
Private Const TV_FIRST = &H1100 Private Const TVM_GETITEMRECT = (TV_FIRST + 4)
Function GetTreeViewNodeRect(ByVal TV As TreeView, ByVal hItem As Long, _ Optional IncludeTextOnly As Boolean) As RECT Dim lpRect As RECT lpRect.Left = hItem If SendMessage(TV.hWnd, TVM_GETITEMRECT, IncludeTextOnly, lpRect) Then GetTreeViewNodeRect = lpRect End If End Function |