Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Systreeview32 search from subtree element
#1
I'm a new QM user, but I'm finding my way around pretty well and liking what I see.  I use macros extensively.  I'm a bit stuck on a SysTreeView though.  When I search for an element, it seems to be searching from the top.  I'm trying to figure out how to tell the App.Find to start searching from a given tree element.

I have a tree that has multiple occurrences of a given text.  For example

+ Device A
   + Interfaces
       + Port 0
           - IP Address
+ Device B
   + Interfaces
       + Port 0
           - IP Address

  
I'm oversimplifying on purpose...  But here's what is going on.  I first find the Device that i'm looking for.  Say it's Device B in this case.  I do something like this:

int w3=win("Gadgets" "Afx:*" "" 0x4)
Acc a3.Find(w3 "OUTLINEITEM" "Device B" "class=SysTreeView32[]id=59648" 0x1035)

act w3
act a3
int c3 = child(a3)
SendMessage c3 LVM_ENSUREVISIBLE a3.elem-1 0 ;; scroll to the location
a3.Select(3) ;; select and focus


Then I want to find the IP Address element of that particular device.  But when I do the following, it almost always finds a leaf element of a different device somewhere higher in the tree.  In this case, I have about 150 devices and each device has about 30 top level children and about a total of 1500 leaf parameters.  I just want to tell the "Find" to start at the "selected" object.

int w=win("Gadgets" "Afx:*" "" 0x4)
Acc a.Find(w "OUTLINEITEM" "IP Address" "class=SysTreeView32[]id=59648" 0x1035)



Any Ideas?
#2
in your example you can use the Navigate function to goto the item
Code:
Copy      Help
int w3=win("Gadgets" "Afx:*" "" 0x4)
Acc a3.Find(w3 "OUTLINEITEM" "Device B" "class=SysTreeView32[]id=59648" 0x15)
a3.Navigate("n3") ;;next next next
a3.Select(3) ;; select and focus
#3
That’s helpful and I have played with that Kevin, but I seriously oversimplified the tree. The leaf element I want to search for could be nested below a dozen (or only 10) subtrees and I won’t always know ahead of time the schema. Unfortunately the item I’m looking for will be replicated in about 100 or so top-level containers (device n in my simplified example). Find is really necessary.
#4
try it this way 

Code:
Copy      Help
int w3=win("Gadgets" "Afx:*" "" 0x4)
Acc a3.Find(w3 "OUTLINEITEM" "Device B" "class=SysTreeView32[]id=59648" 0x15)
rep
,a3.Navigate("n") ; err break
,if(a3.Name="IP Address")
,,a3.Select(3) ;; select and focus
,,break
#5
Thanks Kevin. I’m seeing a path here. I do know the sub folder I’m looking for.

However, is there a message that can be sent and a property that can be interrogated to see if a particular object in the tree is expanded or collapsed? Also the message to expand/collapse. I didn’t find that in my search.

Navigate next works but only if the tree is expanded otherwise the next takes me to “device b”. . I suppose that makes sense. Somewhat like a list.
#6
I just figured out my own question by looking through the MS documentation here:

https://docs.microsoft.com/en-us/windows...-constants
Code:
Copy      Help
if a.State&STATE_SYSTEM_COLLAPSED
    out "Collapsed, expanding"
    a.DoDefaultAction
else
    out "Not Collapsed, doing nothing."
 

After looking at the object properties, I found out that the default action is "Expand" when the State is STATE_SYSTEM_COLLAPSED.  The default action flips to "Collapse" when it's expanded.
#7
Furthermore, I wanted to make sure I resolve to a "leaf" item not a branch.... and this seems to work.  I need to do real stuff with it, not just debug out...  But adding it in case someone else runs into this.
 
Code:
Copy      Help
 
if (a.State&STATE_SYSTEM_COLLAPSED || a.State&STATE_SYSTEM_EXPANDED) ;; if this is a branch item it will be either Collapsed or Expanded
    out "This Seems to be a Branch"
else
    out "This seems to be a Leaf."


Forum Jump:


Users browsing this thread: 2 Guest(s)