PUBLIC frmMyForm, cFilename
SET SAFETY OFF
* Declare variables and initialize.
frmMyForm = CREATEOBJECT("form")
frmMyForm.Width = 100
frmMyForm.ADDOBJECT("oleOutl","myoutline")
DIMENSION aSection(3)
aSection(1) = "Table"
aSection(2) = "Field"
aSection(3) = "Index"
* Create a form, add the custom outline control to the form, and then create an array for the items that the control lists.
cFilename = GETFILE("dbc","Select a DBC")
USE (cFilename)
INDEX ON objecttype FOR (objecttype = "Table" ;
OR objecttype = "Field" ;
OR objecttype = "Index" ) ;
TAG fname
* Prompt for a database that contains the information you want the control to list.
FOR nIndex = 1 TO 3 STEP 1
frmMyForm.oleOutl.AddItem(aSection(nIndex))
frmMyForm.oleOutl.Indent;
((frmMyForm.oleOutl.ListCount-1)) = 1
SCAN
IF objecttype = aSection(nIndex)
frmMyForm.oleOutl.Additem(objectname)
frmMyForm.oleOutl.Indent;
((frmMyForm.oleOutl.ListCount-1)) = 2
ENDIF
ENDSCAN
GO TOP
ENDFOR
* Gather information from the database, and then add it to the control.
frmMyForm.oleOutl.Visible = .T.
frmMyForm.Show
* Make the control visible, and then display the form.
DEFINE CLASS myoutline AS olecontrol
OleClass = "msoutl.outline"
Top = 5
Left = 5
Height = 10
Width = 60
ENDDEFINE
* Define a subclass of the OLE Container control and add the outline control by setting the OleClass property of the container, and then defining other custom settings.
或在form設計器中手工加入