David,
Are you wanting to obtain all tree view items? If so, try this:
Sub TheTreeview()
Dim Win: Set Win = FocusedWindow
If Win.Type <>WtTreeView Then Exit Sub
' Apparently we are in a TreeView:
Speak Win.Type
Speak "You are now in a treeview."
Dim TView: Set TView = Win.Control ' Note that this gives you the
treeview control directly. You do not need to explicitly request a tree
view.
' TreeViewItems was never defined, so I assume you meant to get the
number of items in the tree's top level. In that case:
speak TView.TopLevel.Count
End Sub 'TheTreeview.
Regards,
Steve
On 8/12/2012 8:16 PM, David wrote:
I have the following sub:
Sub TheTreeview()
Dim Win: Set Win = FocusedWindow
If Win.Type <>WtTreeView Then Exit Sub
' Apparently we are in a TreeView:
Speak Win.Type
Speak "You are now in a treeview."
Dim Ctrl: Set Ctrl = Win.Control
Dim TView: Set TView = Ctrl.TreeView
speak TreeViewItems.Count
End Sub 'TheTreeview.
I can place my cursor on anything else but a treview, and the sub will simply
exit. So far, things are alright.
When I put my cursor on a treview, and run this sub, it sure speaks two lines
of info:
22
You are now in a treeview.
Just what I expected it to.
But then it throws an error on me:
Object doesn't support this property or method: 'Ctrl.TreeView'
A bit confused. Likely I am missing something, but can't figure exactly what.
In the documentation of WE, it states under TreeView:
Usage
Use a
TreeView
object to retrieve information regarding a tree view control. A
TreeView
object can be obtained from a
Window
object's
Control
method when the
Window
object's
Type
is
wtTreeView
In my sub, I set an object (Win) from the FocusedWindow. Then another object
(Ctrl) from that Window object's Control. Isn't that what the documentation
claims to be the way to go? And from here, I should have been able to retrieve
the TreeView object. What am I missing?
Thanks for any guidance.
--
Stephen Clower
Product support specialist & App Development
GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825
260-489-3671 * gwmicro.com