David,

      I placed the routines you will need first instead of last to make it more 
readable for you. The .clear command has to be performed and where to place all 
of it is your choice.
          Bruce
      this is the part of the Uninstall that calls the making of the tree and 
resetting of it.
      When the program first starts it calls getTree and when refreshing or 
repopulating you call the ResetTree routine.

          Bruce


  Function MainDialog
  Case Else
  If dEvent = dialogCreated Then
      ' This routine is to init all buttons and fields.
      Silence
      Set myAltF4 = Keyboard.RegisterHotkey("Alt-F4", "ExitMenu", dObj.Window, 
dObj)
      Set myAddDialog = Nothing
  'And many more...
      dObj.Window.Activate
      If dObj.Window.Status = wsMinimized Then
       dObj.Window.Status = wsNormal
      End If
      myMainDialog.Control( "btn_refresh").Enabled = True
  'And many more enables....
      ' Set Tree View:
      queue "Get_Tree", myMainDialog
  '    myMainDialog.Control( MyTreeName).Focus()
      MainDialogProc = True
      Exit Function
     ElseIf dEvent = dialogClosing Then
     'do something else.

  David this is what you need:



    Sub Get_Tree( dObj)
     ResetTreeView dObj, MyTreeName, "Programs Listed By " & treeSortNames( 
TV_Sort-TV_SortByName) & ":", 0
     GetAllTreeLeaves MyTreeName, dObj.Control( MyTreeName).Root, dObj, 
treeSearchNames
    ' StartTimer  250,
     LoadingPrograms = False
     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
     Dim tvRoot
     Set tvRoot = dObj.Control( treeId).NewItem
     tvRoot.Text = nodeName
     tvRoot.Data = nodeData
     dObj.Control( treeId).TopLevel.Insert tvRoot, tviRoot
    End Sub

  'This is original and an array has to be passed in.
  ' The array is either the program list or the list of choice of listing.
  ' 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.
  Sub GetAllTreeLeaves( treeName, lastNode, dObj, dArray)
   Dim tChildName, tCount, tMax, tLevel, tSubLevel, i, j
   Dim tvNewChild, tvNewChildChildren, tvNewChildChildrensChildren, 
tvNewChildChildrensChildrensSibblings
   tCount = -1
   For Each tChildName In dArray
    tCount = tCount + 1
    Reduce_SetArray tCount ' Make array.
    doSorting TV_Sort 'Sort by 1=names, 2=date.
    tMax = treeNameCount( tCount)
    Trim( tChildName)
    If tChildName <> "" Then tChildName = "By " & tChildName
    ' Add count to tree name
    tChildName = "All Programs " & tChildName & " (" & tMax & ")"
    ' Now create sub tree level with a name and data.
    GetChildNode treeName, lastNode, tvNewChild, dObj, tChildName, tCount+1
    For i = 0 to tMax-1
     tChildName = arrayAllByName( i, TV_SortByName)
     If tChildName = "" Then tChildName = "No Name(" & i+1 & ")"
     tLevel = (tCount+1) * 1000000 + i * 1000 'Based on no more than 999 
programs and 1000 properties per on computer.
     GetChildNode treeName, tvNewChild, tvNewChildChildren, dObj, tChildName, 
tLevel
     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.
      ' Sort arrays start at 0 so column does also.
      tChildName = arrayAllByName( i, j-1)
      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
    Next
   Next
  End Sub

  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

  ' Init Main Program Parms
  Dim strAllTitle, strUnInstallTitle
  Dim programArray(), programTypeArray()
  Dim intAllCount, intUnInstallCount
  intAllCount = Int(0): intUnInstallCount = Int(0)
  Dim arrayAllByName(), arrayUnInstallByName(), arrayAllByHotfix(), 
arrayUnInstallByHotfix(), arrayAllByUpdate(), arrayUnInstallByUpdate()
  strAllTitle = "The Installed Applications Total Is: "
  strUnInstallTitle = "The UnInstallable Applications Total Is: "

  Sub AlphabeticalListOrderToggles( myKeyId)
   'This routine is called when the hotkey Alt-A is pressed.
   If Keyboard.KeyDescriberActive Then
    Speak myStrings(myKeyId & "_Description"), speakerVoice
   Else
    'Main routine functionality goes here
    TV_Sort = TV_SortByName
    Silence
    Speak " Sorting Program Lists By Name! ", speakerVoice
    queue "Get_Tree", myMainDialog
   End If
  End Sub

  Sub ListProgramsByDateToggles( myKeyId)
   'This routine is called when the hotkey Alt-D is pressed.
   If Keyboard.KeyDescriberActive Then
    Speak myStrings(myKeyId & "_Description")
   Else
    'Main routine functionality goes here
   TV_Sort = TV_SortByDate
    Silence
    Speak " Sorting Program Lists By Date! ", speakerVoice
    queue "Get_Tree", myMainDialog
   End If
  End Sub

  Sub ActivatesTheUninstallProgramApp(myKeyId)
   'This routine is called when the hotkey Control-Shift-U is pressed.
   If Keyboard.KeyDescriberActive Then
    Speak myStrings(myKeyId & "_Description")
   Else
    'Main routine functionality goes here
    Speak " You Just Activated Uninstall Program. "
    Queue "LaunchUnInstallDialog"
   End If
  End Sub

  Sub LaunchUnInstallDialog()
   Speak " please wait a few seconds for the sorted list to be loaded and 
displayed. "
   GetAllPrograms
   LaunchMainDialog
  End Sub

  Sub GetAllPrograms()
   LoadingPrograms = True
   ' Load arrays
   GetPrograms intAllCount, intUnInstallCount
  End Sub

  Sent: Wednesday, January 29, 2014 7:07 AM
    Subject: Treeview experience, some interesting observations


    Listers,
    I have been playing around with the Treeview in a couple of my projects 
lately. And, I have been looking at a few Apps, to get the idea of how to 
handle the Treeview. Things basically are up running by now, but I have made a 
couple of interesting observations. I wonder if I am misunderstanding 
something, or if there is a whole in my knowledge. Likely some of you, have 
made similar experiences.

    First of all, I made a Dialog in the XML, holding a Treeview, and two 
buttons - like an OK, and a Cancel button. Things got more advanced later on, 
but for now, let's concentrate on this basic Dialog.

    Next, back to the code, and build a Queued sub, to call the Dialog Handler 
function of the Treeview Dialog. All that, worked just fine, and I got things 
to display on the screen.

    Now was the time, to start fill in the information in the Treeview. The 
info I needed, was all stored in a file on the computer, so to retrieve it, and 
have it correctly filled into the Tree, was quite easy. After all, the treeview 
I am working on in one project, only holds the Root, and some entries in the 
first Child level.

    To make all the filling of the tree easy as possible, I placed all of that 
processing stuff, in a sub, called "FillTree". I pass the Treeview object, as 
the parameter to the sub, from inside my Dialog Handler. Something like:

        FillTree DObj.Control( "MyTreeview")
        DialogHandler = True
        Exit Function

    Fine. The Treeview gets filled, with something like ten entries in the 
Root, and anything from one to ten entries in the first sublevel for each Root 
entry. All as expected. Yet, now comes my observations.

    Running the app, the Dialog opens, and you land on the Treeview. The 
FillTree routine has been called, so your screen will show a treeview, with ten 
entries in the Root. You now try to tab to the OK button, and then tab back to 
the Treeview. What do you think, other than now your treeview will hold twenty 
entries in the root. Perform the act ten times, and your entries will be 
tenfold in the root. OK, I see what is the case, everytime I land on the 
treeview, the FillTree sub is called, causing it to add on the same entries all 
over, thereby raising the number of entries. The stuff is basic enough this far.

    My question number one to all of you experienced ones, is:
        Where in the Dialog Handler should I perform the FillTree call?
    I thought, based on primitive thinking, that I could place it near the end 
of the Handler. There, I have a section like this:
        Case Else
            If DialogCreated Then
                FillTree DObj.Control( "MyTreeview")
            ElseIf DialogClosing Then
            BlahBlahBlah

    Since I reasoned this section would only be effective when the Dialog was 
all created, I thought this would be the place to fill in the Treeview. Yet, it 
seems for some strange reason, that I was wrong. My testing has revealed, that 
the stuff in the above samplified section, will be executed on each move I make 
in the Dialog, and thereby keep "filling things into the treeview", whenever I 
tab around.

    OK, I figured one solution, in that I let the FillTree sub, start out by a 
Clear command, to start with an empty treeview, and refilling it from scratch, 
everytime the call comes. But, that also lead to another issue, as now I will 
keep ending up at the top of the treeview, everytime I tab away, and back to 
the tree.

    I further figured, that I could store the selected Node, at any given time, 
and let the FillTree sub conclued every run, by focusing the stored 
selectedNode. That works just fine, long as I am in the Dialog operating. And, 
if I hit the Cancel button of the Dialog - which simply cause a
        DObj.Close
    call inside the Dialog Handler, the stuff may work in some cases. What 
happens, is that long as I am focusing the root of the treeview, then hitting 
the Cancel button, things close troublefree. But, when I have expanded one of 
the Root Nodes, and focused a Node on the first sublevel, then hit the Cancel 
button, the dialog close, and the screen reader crashes altogether. It actually 
crashes that much, you get this three-note tiny tune, and the computer hangs 
for several minutes, before Window-Eyes let go of the system - a behavior that 
in general is a clear drawback of WE. OK, my question number two, for you guys, 
is:
        Do any of you have a clue what could cause this kind of crashing, just 
because a Child Node is focused, when the dialog is being closed?
    It even happens, if there is no other activity going on, as a direct result 
of the Node being focused. Just this simple sample I here have described. 
Whether it is because I need to erase any objects before closing the Dialog, or 
If I am missing some essential point, I am not aware. Yet, I did try two 
things, with no further success.

    First, I started out the FillTree sub, by a line, indicating that if the 
parsed object - from the Dialog Handler - is empty the sub should exit 
immediately. My hope was, that no other attempt to fill in a closing treeview, 
would have fixed the trouble of crashing. Next, I tried to set the treeview 
control to nothing, as part of the closing routine in the Dialog Handler. None 
of it worked to my satisfaction.

    Finally, I thought, maybe it could be due to the FillTree sub trying to 
focus the selected node, upon each redraw of the treeview. OK, so I removed 
that line in the sub, and now it seems not to crash, whenever I close the 
Dialog. OK, any ideas as to if I could have worked around all that closing 
trouble? Should I have erased any further objects, or how can I make the user 
selected node focusing all the time, and still have the dialog closing 
properly? Not even On Error Resume Next, would work for troublefree closing. 
And, as stated above, how can I prevent the treeview from refilling everytime 
you tab back and forth in the dialog?

    Sorry for the rather long explanation. Hope someone have had some 
experience and found working ideas. As I said, I have looked at other codings, 
and thought I had done much of the same procedures as the rest of you. Yet, all 
this trouble. Smile. What really puzzles me, is why things in the DialogCreated 
section, keep repeating for each tabbing around. Maybe I am misinterpretting 
that instruction, but I thought it would only fire, when the Dialog is 
initiated, hence I could perform a "one-time" action in that section. 
Apparently not, so any other ideas are welcome.

    thanks,




------------------------------------------------------------------------------
          This email is free from viruses and malware because avast! Antivirus 
protection is active.




---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com

Reply via email to