Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use the Outline Control Activex to show a directory .

Classes and Objects

How to use the Outline Control Activex to show a directory .

by  Mike Gagnon  Posted    (Edited  )
Here is an example of showing a directory structure using the seldom used Outline Control (This sample assumes that the Outline Control exist on your system which comes installed with Visual Studio or Visual Studio .NET - File name MSOutl32.OCX). Copy the following in a program and run it.
Code:
Public oform1
oform1=createobject("form1")
oform1.AddObject("oleOut","out")
oform1.Show
Return
Define Class form1 As Form
    Height = 352
    Width = 433
    DoCreate = .T.
    AutoCenter = .T.
    Caption = "Demo directory display"
    AlwaysOnTop = .T.
    Name = "Form1"
    Add Object text1 As TextBox With ;
        Height = 25, ;
        Left = 12, ;
        Top = 312, ;
        Width = 265, ;
        BackColor = Rgb(192,192,192), ;
        Name = "Text1"
    Add Object command1 As CommandButton With ;
        AutoSize = .T., ;
        Top = 312, ;
        Left = 288, ;
        Height = 27, ;
        Width = 88, ;
        Caption = "Get Directory", ;
        Name = "Command1"
    Procedure createarray
    Lparameters m.path, m.nlevel, m.nCount
    Local DirArr,i,nTotDir,lvl
    Store 0 To i,lvl,Cnt
    m.path = Alltrim(m.path)
    If Parameters()<2 Or Type("m.nlevel") #"N"
        lvl = 0
    Else
        lvl = m.nlevel
    Endif
    If Parameters()<2 Or Type("m.nCount") #"N"
        Cnt = 0
    Else
        Cnt = m.nCount
    Endif
    lvl = lvl + 1
    Cnt = Cnt + 1
    o = This.oleOut
    If Cnt = 1
        o.AddItem(Lower(m.path))
        o.Indent(Cnt-1)=1
    Else
        o.AddItem(Lower(m.path))
        o.Indent(Cnt-1)=m.lvl
    Endif

    Dimension DirArr[1,1]
    nTotDir=Adir(DirArr,m.path+"*.","D")
    Asort(DirArr)
    For i = 1 To m.nTotDir
        If DirArr[m.i,1] != '.' And DirArr[m.i,1] != '..' And Atc('D',DirArr[m.i,5])#0
            This.createarray(m.path+DirArr[m.i,1]+'\', m.lvl, m.cnt)
        Endif
    Endfor
Endproc
    Procedure command1.Click
    Local cDir
    If Thisform.oleOut.Object.ListCount > 0
        Thisform.oleOut.RemoveItem(0)
    Endif
    cDir = Getdir()
    If Empty(m.cDir)
        Return
    Else
        Thisform.text1.Value = m.cDir
    Endif
    If Thisform.oleOut.Object.ListCount>0
        Thisform.cleanuP()
    Endif
    Thisform.createarray(m.cDir)
Endproc
Enddefine
Define Class out As OleControl
    Top = 24
    Left = 24
    Height = 193
    Width = 289
    Visible = .T.
    OleClass='msoutl.outline'
Enddefine

Mike Gagnon
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top