Jump to content

SysTreeView control issues...


Recommended Posts

I have a SysTreeView control that I cannot extract the text from.

I am trying to process a SysTreeView control, that is, I want a total count of the nodes in the structure, loop through it looking for a particular string, and then expand that node to look at one of the sublevels.

Naturally, what would appear simple is not.

Here is the code I am using:

CODE

Func Preferences()

WinMenuSelectItem("J2EE - IBM Rational Software Development Platform", "", "&Window", "&Preferences" )

; Raise the "Preferences" panel...

WinWait("Preferences", "")

WinActivate("Preferences", "")

; Define a few useful variables...

Local $hWnd = "Preferences"

Local $hDebugFile = "C:\Temp\Preferences.txt"

Local $aWGCI = _WinGetCtrlInfo($hWnd)

Local $sClassNameNNN

Local $nControlID

Local $hOutput = " " & @CRLF & @CRLF

FileClose(FileOpen($hDebugFile, 10))

$hOutput &= '---------------------------------' & @CRLF

$hOutput &= 'Contents of the Preferences panel' & @CRLF

$hOutput &= '---------------------------------' & @CRLF

$hOutput &= ' ' & @CRLF

For $iCC = 1 To $aWGCI[0][0]

ControlFocus($hWnd, '', $aWGCI[$iCC][0])

If StringInStr($aWGCI[$iCC][0], "SysTreeView") Then

$sClassNameNNN = $aWGCI[$iCC][0]

$nControlID = $aWGCI[$iCC][1]

$hOutput &= "$sClassNameNNN = " & $sClassNameNNN & ", $nControlID = " & $nControlID & @CRLF & @CRLF

ExitLoop

EndIf

Next

$nNodeCnt = _TreeView_GetVisibleCount($nControlID)

$hOutput &= 'Total Nodes = ' & $nNodeCnt & @CRLF

; We need to process the lone SysTreeView control...

For $iNC = 1 to $nNodeCnt

; Try to pull the label directly from the SysTreeView control...

$TreeVar = _TreeView_GetText($nControlID, $iNC)

$hOutput &= "Preference label for Node #" & $iNC & " is " & $TreeVar & @CRLF

; Try to pull the label indirectly from the corresponding SWT_Window0 control...

;$SWTVar = ControlGetText("Preferences", "", "SWT_Window" & $i)

Next

Return FileWrite($hDebugFile, $hOutput)

EndFunc

And here is the output of the function:

CODE

---------------------------------

Contents of the Preferences panel

---------------------------------

$sClassNameNNN = SysTreeView321, $nControlID = 132026

Total Nodes = 27

Preference label for Node #1 is

Preference label for Node #2 is

Preference label for Node #3 is

Preference label for Node #4 is

Preference label for Node #5 is

Preference label for Node #6 is

Preference label for Node #7 is

Preference label for Node #8 is

Preference label for Node #9 is

Preference label for Node #10 is

Preference label for Node #11 is

Preference label for Node #12 is

Preference label for Node #13 is

Preference label for Node #14 is

Preference label for Node #15 is

Preference label for Node #16 is

Preference label for Node #17 is

Preference label for Node #18 is

Preference label for Node #19 is

Preference label for Node #20 is

Preference label for Node #21 is

Preference label for Node #22 is

Preference label for Node #23 is

Preference label for Node #24 is

Preference label for Node #25 is

Preference label for Node #26 is

Preference label for Node #27 is

First, the number of nodes (27) does not match what I am actually seeing on the screen (22).

Second, I cannot extract the label/text from each node for inspection (they are all blank).

I assume I'm doing something stupid, but I just cannot see it. Anyone got any suggestions? :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...