INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Classes and Objects

How to use the Outline Control Activex to show a directory . by mgagnon
Posted: 30 Jan 03

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.

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

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close