Hi David,
There is a simple neat trick for all your items and lengthy list. That is
a dictionary. That means you can use both digits and letters, in which you are
now using 0 to 9 and 1 to 26, which expands each digit to 36 instead of 9. From
there you have essentially made each digit as a power of 36. That will not blow
any mind, nor computer.
So use a dictionary, load it from a file on .ini file, what ever you decide.
As I stated below, you have a data collection to draw from, an array, or
as mentioned above, a dictionary, where you can get any item from the list
instantly using a dictionary key.
It all becomes your imagination. The data field reflects where in the
dictionary you are, an easy thing to do, for it should reflect your data
columns...
Below is a summary of what I do. I added notes to it and I am using a 3
level tree
and this reflects only those 3 levels.
In other words there are sort items at the top level, (all programs or
types,) then the list of programs at the second level, then at the third level
are the properties of that program
given out under WMI commands...in other words what is listed in the registry
for that installed program.
These are the routines in making a tree and it's children.
These routines are called over and over again each time a new leaf is made.
Sub Get_Tree( dObj)
' David, below is my program and beneath it are the direct names inside the
calling parameter list:
ResetTreeView dObj, MyTreeName, "Programs Listed By " & treeSortNames(
TV_Sort-TV_SortByName) & ":", 0
'ResetTreeView( dObj, treeId, nodeName, nodeData)
'Make the tree:
GetAllTreeLeaves MyTreeName, dObj.Control( MyTreeName).Root, dObj,
treeSearchNames
' GetAllTreeLeaves( treeName, lastNode, dObj, dArray)
'Note above on what is being called! What each parm really means.
'Note2: the array I use for each level of the tree...
'Now go to the top level for focus:
Queue "SetTreeFocus", dObj.Control( MyTreeName)
End Sub
Sub ResetTreeView( dObj, treeId, nodeName, nodeData)
'Reset programs Tree View level based on ID.
dObj.Control( treeId).Clear
' clearing the control based on id, just plain removing it since we are in
reset mode.
'Now below we are making the tree all over again, starting at it's root:
Dim tvRoot
Set tvRoot = dObj.Control( treeId).NewItem
' Attaching the very first item on the tree above, it's first limb, in this
case, the trunck.
'Below attaching a name to the first item and a ID (data) which is exposed
when selected or clicked on:
tvRoot.Text = nodeName
tvRoot.Data = nodeData
' Remember David the node data is what you assign to it, a number.
'The text, can be anything, such as a color name.
'Note: above is for the actual trunck, the top of the tree, so below:
dObj.Control( treeId).TopLevel.Insert tvRoot, tviRoot
'Note: The text and ID you gave it is now at the top of the tree.
' Above is the actual insert command and being inserted is the item called
tvRoot, which you made above it.
End Sub ' End of the making of a tree.
'Making leaves of the tree an array has to be passed in.
' The array is either the program list or the list of choice of listings,
like your colors or pants and such.
' In other words the first time through is the 4 choices and the call inside
is the program array associated to it.
' Any sub call is another routine just like this for the program list.
' What I am saying David is you know what sub levels you want, they are the
array used when calling this routine each time, the sub level list is the array
passed in.
Sub GetAllTreeLeaves( treeName, lastNode, dObj, dArray)
' Note above the name lastNode, the node that gets a new branch.
Dim tChildName, tCount, tMax, tLevel, tSubLevel, i, j
Dim tvNewChild, tvNewChildChildren, tvNewChildChildrensChildren,
tvNewChildChildrensChildrensSibblings
'Note: we are getting all needed values for the children being made,
including the array counter.
'Note: all arrays start at 0 or 0 based.
tCount = -1
For Each tChildName In dArray
' Now lets get all the array items to store in the limbs leaves.
tCount = tCount + 1
'Note if you have an array of several dimensions, you want the max of that
dimension, which is done below:
tMax = treeNameCount( tCount)
'Note above is another array that stores the maximum number of items at that
level.
'Now making sure there are no spaces in the name:
Trim( tChildName)
' Adding to the name if you want to, but that is just an option:
If tChildName <> "" Then tChildName = "By " & tChildName
' Add count to tree name
tChildName = "All Programs " & tChildName & " (" & tMax & ")"
' Above you also have added to the level name is how many children are in
that level added to the name.
' Now create sub tree level with a name and data.
'Note: The node values go in empty but comes back filled as a tree object:
'Note that the last item on the parameter list is an ID value for the data
field:
GetChildNode treeName, lastNode, tvNewChild, dObj, tChildName, tCount+1
' Note: above is a leaf and below will be it's children.
For i = 0 to tMax-1
' Note below there is another array and that array is all your selections you
want on the list, you can define it any way you want to:
tChildName = arrayAllByName( i, TV_SortByName)
If tChildName = "" Then tChildName = "No Name(" & i+1 & ")"
' Note: below is that power of ten ID level control I spoke about to identify
what you have selected inside the data property:
tLevel = (tCount+1) * 1000000 + i * 1000 'Based on no more than 999
programs and 1000 properties per on computer.
'Now that you have the name, the level ID, now make the child of the leaf:
GetChildNode treeName, tvNewChild, tvNewChildChildren, dObj, tChildName,
tLevel
'Note: The above routine is always used to make a child of a leaf...
'Below is the complete sub level of a given leaf of the tree, the second
dimension of the array.
'This is only a 2 dimensional array but could be more based on how many
levels you want in your tree.
errorCount = 0
' Count 1 to max for tree collection items start at 1.
Dim itemNum: itemNum = 1
For j = 1 to maxColumns
tSubLevel = tLevel + itemNum 'Based on less than 1000 sort and data
fields.
' arrays start at 0 so column does also.
tChildName = arrayAllByName( i, j-1)
'Note: below are options you can force into the name if you want, an easy
labeling system.
' What I did is each array Item I am marking it's actual meaning and
inserting it into it's display name.
Select Case j
Case 1: tChildName = "Product Key: " & Trim( tChildName)
Case 2: tChildName = "Program Name: " & Trim( tChildName)
Case 3: tChildName = "Install Date: " & GetDate( tChildName)
Case 4: tChildName = "Version: " & Trim( tChildName)
Case 5: tChildName = "Size: " & Trim( tChildName)
End Select
If j <= maxSimpleColumns Or Len( tChildName) > (Len( ProgramProperties(
j-1)) +2) Then
' tChildName = tChildName & "(" & Len( tChildName) & ") (" & Len(
ProgramProperties( j-1)) & ")"
itemNum = itemNum + 1
GetChildNode treeName, tvNewChildChildren, tvNewChildChildrensChildren,
dObj, tChildName, tSubLevel
End If
Next ' Step Through each sub level.
Next
Next
End Sub
'Note: below is the making of each tree item:
Sub GetChildNode( treeName, parentNode, tvINew, dObj, tvText, tvData)
Set tvINew = dObj.Control( treeName).NewItem()
tvINew.Text = tvText '& tvData
tvINew.Data = tvData
' Note below last node is parent and created is child.
parentNode.Children.Insert tvINew, tviLast
End Sub
'Note: David, below are triggered test routines based on selection or click
of a tree view item:
Sub TreeItemClicked( dObj)
' Speak " Name Is: " & TV_Name & " Item " & TV_Data & " Whose Item Was Mouse
Clicked "
'List all Case selections here
End Sub
' Note: below I use the space bar to make a selection and it looks for the
key that did the clicking:
Sub OnKeyProcessedUp( ky, md)
Disconnect myTV_KeyConnection
myTV_KeyConnection = 0
If TV_KeyDown and ky = vk_Space and md = 0 Then
Silence
Queue "LaunchURLEmail"
' myMainDialog.Control( "btn_uninstall").Focus()
End If
TV_KeyDown = False
End Sub
'Note: David Above I used a keyboard key, below I just use a mouse click:
Sub OnButtonUp( button)
Disconnect myTV_MouseConnection
myTV_MouseConnection = 0
If TV_MouseDown and button = 0 Then
Queue "LaunchURLEmail"
' myMainDialog.Control( "btn_uninstall").Focus()
End If
TV_MouseDown = False
End Sub
Sub LaunchURLEmail()
' Do Internet or email launch.
If Not SO_LaunchUrl Is Nothing Then
If Instr(1, TV_Name, "http://", VbTextCompare) > 0 Then
' For type of compare you have to specify start point of search:
Speak " Launching Internet Link. "
Sleep 1000
SO_LaunchUrl Mid( TV_Name, Instr(1, TV_Name, "http://", VbTextCompare))
End If
If Instr(1, TV_Name, "@", VbTextCompare) > 0 And (Instr(1, TV_Name, ".org",
VbTextCompare) > 0 Or Instr(1, TV_Name, ".com", VbTextCompare) > 0 Or Instr(1,
TV_Name, ".net", VbTextCompare) > 0) Then
Speak " Launching Email. "
Sleep 1000
SO_LaunchUrl "MailTo://" & Mid( TV_Name, Instr(1, TV_Name, ": ",
VbTextCompare) +2)
End If
Else
Speak " The Launch Utility Is Not Available! ", speakerVoice
Sleep 2000
End If
End Sub