Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Treeview
Message
General information
Forum:
Visual FoxPro
Category:
Third party products
Title:
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01013476
Message ID:
01013556
Views:
15
Craig:

I have mentioned this before, but a little heads-up is in order.
Although this sample is fine for most people, if you happen to work in the corporate world as I do, this code attempts to read in all of the corporate network. In the case of a multinational corporation, as is my case, this will get information form remote places you may have never even heard of. IOW, sloooowww!

In my case, I added IF UPPER(lofolders.Item(lnCounter).Name) != "PUBLIC FOLDERS" as shown below, and now, even though I have a very large local tree (local folders) it runs very fast.

Of course you could make this optional by asking a question but that's not relevant to the issue. Good sample BTW.

Just some $0.02
...
FOR lnCounter = 1 TO loFolders.COUNT
   IF UPPER(lofolders.Item(lnCounter).Name) != "PUBLIC FOLDERS"
     lcKey = THISFORM.NewKey()
     loNode = THISFORM.olecontrol1.Nodes.ADD(,, lcKey, loFolders.ITEM(lnCounter).NAME, 0)
     loNode.Expanded = .T.
     IF TYPE("loFolders.ITEM(lnCounter).Folders.count") = "N"
        IF loFolders.ITEM(lnCounter).Folders.COUNT > 0
           THISFORM.GetChildren(loFolders.ITEM(lnCounter).folders, lcKey)
        ENDIF
     ENDIF
   ENDIF
ENDFOR
...
>IMHO the MS TV is an amazing control, and it's free. Below is an example using MS Treeview Control 6 (SP4). Cut-n-paste the code into a prg and execute it...
>
PUBLIC goForm
>goForm = CREATEOBJECT("form1")
>goform.show()
>
>DEFINE CLASS form1 AS form
>
>    Top = 3
>    Left = 0
>    Height = 450
>    Width = 285
>    DoCreate = .T.
>    Caption = "Outlook Folders Enumerated"
>    nextkey = "1_"
>    Name = "Form1"
>    lastkey = .F.
>    showtips=.T.
>    Dockable = 1
>	
>    ADD OBJECT olecontrol1 AS olecontrol WITH ;
>        Appearance = 0, ;
>        Top = 0, ;
>        Left = 0, ;
>        Height = this.height , ;
>        Width = this.Width , ;
>        Name = "Olecontrol1", ;
>        OleClass= "MSComctlLib.TreeCtrl.2",;
>        Anchor = 15
>	
>    PROCEDURE Init
>        thisform.loadtreeview()
>        thisform.Dock(1)
>    ENDPROC
>	
>    PROCEDURE loadtreeview
>        LOCAL loOutlook, loNameSpace, loFolders, lcKey, loNode, lnCounter
>
>        loOutlook = CreateObject('Outlook.Application')
>        loNameSpace = loOutlook.GetNameSpace('MAPI')
>        loFolders = loNameSpace.Folders
>
>        FOR lnCounter = 1 TO loFolders.COUNT
>            lcKey = THISFORM.NewKey()
>            loNode = THISFORM.olecontrol1.Nodes.ADD(,, lcKey, loFolders.ITEM(lnCounter).NAME, 0)
>            loNode.Expanded = .T.
>            IF TYPE("loFolders.ITEM(lnCounter).Folders.count") = "N"
>                IF loFolders.ITEM(lnCounter).Folders.COUNT > 0
>                    THISFORM.GetChildren(loFolders.ITEM(lnCounter).folders, lcKey)
>                ENDIF
>            ENDIF
>        ENDFOR
>
>        loNameSpace = NULL
>        loOutlook = NULL
>        RELEASE loNameSpace
>        RELEASE loOutlook
>    ENDPROC
>
>    PROCEDURE getchildren
>        LPARAMETERS toFolder, tcKey
>        LOCAL loNode, lnCounter
>        FOR lnCounter = 1 TO toFolder.COUNT
>            lcKey = THISFORM.NewKey()
>            loNode = THISFORM.olecontrol1.Nodes.ADD(tcKey, 4, lcKey, toFolder.ITEM(lnCounter).NAME, 0)
>            loNode.Expanded = .T. && Take this line out to speed display
>            IF TYPE("toFolder.ITEM(lnCounter).Folders.count") = "N"
>                IF toFolder.ITEM(lnCounter).Folders.COUNT > 0
>                    THISFORM.GetChildren(toFolder.ITEM(lnCounter).folders, lcKey)
>                ENDIF
>            ENDIF
>        ENDFOR
>    ENDPROC
>
>    PROCEDURE newkey
>        *!* Procedure Borrowed from VFP example in Solution
>        lcKey = THIS.NextKey
>        THIS.NextKey = ALLTRIM(STR(VAL(THIS.NextKey) + 1) + "_")
>        RETURN lcKey
>    ENDPROC
>
>ENDDEFINE


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform