Mini Kabibi Habibi

Current Path : C:/Users/ITO/Desktop/VF9/program files/microsoft visual foxpro 9/samples/solution/ole/
Upload File :
Current File : C:/Users/ITO/Desktop/VF9/program files/microsoft visual foxpro 9/samples/solution/ole/bldtree.sct

P�VERSION =   3.00dataenvironmentdataenvironmentDataenvironmentKLeft = 10
Top = 326
Width = 507
Height = 146
Name = "Dataenvironment"
12formformForm1�DataSession = 2
Top = 3
Left = 6
Height = 297
Width = 568
DoCreate = .T.
Caption = "Add and Remove Items in a Treeview Control"
MaxButton = .F.
WindowState = 0
HelpContextID = 104
cnextkey = 1_
cdbfname = 
Name = "Form1"
%PROCEDURE newkey
cKey = THIS.cNextKey
THIS.cNextKey = ALLTRIM(STR(VAL(THIS.cNextKey) + 1) + "_")
RETURN cKey
ENDPROC
PROCEDURE refreshcombo
THIS.cboParent.Clear
For i = 1 TO THIS.oleTree.Nodes.Count
	THIS.cboParent.AddListItem(THIS.oleTree.Nodes.Item(i).FullPath, i, 1)
ENDFOR

ENDPROC
PROCEDURE verifytablestructure
LOCAL laFields[1,11], lnPos, laNeeded[3], lnCnt

#DEFINE FIELD1_LOC "KEY"
#DEFINE FIELD2_LOC "PARENT"
#DEFINE FIELD3_LOC "TEXT"

* Make sure the table contains the right fields.
*-----------------------------------------------
laNeeded[1] = FIELD1_LOC
laNeeded[2] = FIELD2_LOC
laNeeded[3] = FIELD3_LOC


=AFIELDS(laFields,ALIAS())

FOR lnCnt = 1 TO ALEN(laNeeded)
	lnPos = ASCAN(laFields, laNeeded[lnCnt])
	IF lnPos = 0 OR laFields[lnPos+ 1] != 'C'
		#DEFINE TITLE_LOC "Invalid Table Structure"
		#DEFINE MSG_LOC "The table must contain 3 character fields:" + CHR(13) + ;
			CHR(13) + FIELD1_LOC + ;
			CHR(13) + FIELD2_LOC + ;
			CHR(13) + FIELD3_LOC
		=MESSAGEBOX(MSG_LOC,48+0+0,TITLE_LOC)
		RETURN .F.
	ENDIF
ENDFOR

RETURN .T.
ENDPROC
PROCEDURE opendbf
LPARAMETERS lcDBFName, llExclusive

* assume success.  If there is an error, THISFORM.OpenedSuccessfully 
* will be set to .F. in the Error event
THISFORM.OpenedSuccessfully = .T. 

#DEFINE ERR_LOC "Error"
IF !FILE(lcDBFName)
	#DEFINE ERR1_LOC "Cannot find the specified file."
	=MESSAGEBOX(ERR1_LOC,48+0+0,ERR_LOC)
	RETURN .F.
ENDIF

lcAlias = SUBSTR(lcDBFName, RAT("\",lcDBFName) + 1)
lcAlias = SUBSTR(lcAlias, 1, AT(".", lcAlias) - 1)

IF llExclusive
	USE (lcDBFName) IN 0 EXCLUSIVE
ENDIF

IF !USED(lcALIAS)
	USE (lcDBFName) IN 0 SHARED
ENDIF

SELECT (lcALIAS)

RETURN THISFORM.OpenedSuccessfully



ENDPROC
PROCEDURE checkbuttons
o = THISFORM.oleTree
IF ISNULL(o.SelectedItem) THEN
	THISFORM.cmdNewChild.enabled = .F.
	THISFORM.cmdDeleteNode.enabled = .F.
ELSE
	THISFORM.cmdNewChild.enabled = .T.
	THISFORM.cmdDeleteNode.enabled = .T.
ENDIF
ENDPROC
PROCEDURE Init
IF  fontmetric(1, 'MS Sans Serif', 8, '') # 13 OR ;
	fontmetric(4, 'MS Sans Serif', 8, '') # 2 OR ;
	fontmetric(6, 'MS Sans Serif', 8, '') # 5 OR ;
	fontmetric(7, 'MS Sans Serif', 8, '') # 11
	this.setall('fontname', 'Tahoma')  
ELSE
	this.setall('fontname','MS Sans Serif')
ENDIF
this.setall('fontsize',8)

* Check to see if OCX installed and loaded.
IF TYPE("THIS.oleTree") # "O" OR ISNULL(THIS.oleTree)
	RETURN .F.
ENDIF
ENDPROC
PROCEDURE Error
LPARAMETERS nError, cMethod, nLine
#DEFINE ERRMSG_LOC "Error"
#DEFINE ERR3_LOC "The table is in use and could not be opened exclusively."
DO CASE
	CASE nError = 1426
		*!* Ignore error 1426
	CASE nError = 3  && File in use
		MESSAGEBOX (ERR3_LOC, 0, ERRMSG_LOC)
		THISFORM.OpenedSuccessfully = .F.
	OTHERWISE
		MESSAGEBOX (ALLTRIM(STR(nError)) + SPACE(5) + MESSAGE(), 0, ERRMSG_LOC)
		THISFORM.OpenedSuccessfully = .F.
ENDCASE
ENDPROC
PROCEDURE Activate
THIS.c_solutions1.saveHelp
ENDPROC
PROCEDURE Deactivate
IF TYPE("THIS.c_solutions1") = "O" THEN
	THIS.c_solutions1.restoreHelp
ENDIF
ENDPROC

�� �	�	�*	%�	M��U>T������"T���CCC��g�Z�_���	B����UCKEYTHISCNEXTKEY_
����� �����(�������X�+��CC������	���������U
THIS	CBOPARENTCLEARIOLETREENODESCOUNTADDLISTITEMITEMFULLPATHp%���������������T������KEY��T������PARENT��T������TEXT����C��C��������(�C���b�T��C�C�����%%����C����C��^����C�*The table must contain 3 character fields:C�
 C�
 �KEYC�
 �PARENTC�
 �TEXT�0�Invalid Table Structure�x��B�-�����B�a��ULAFIELDSLNPOSLANEEDEDLNCNT����T���a��%�C�0
��f�6��C�Cannot find the specified file.�0�Error�x��B�-���T��C�C�\���\��T��C��C�.��\��
%������Q�������%�C��
����Q������
F����B�����U	LCDBFNAMELLEXCLUSIVETHISFORMOPENEDSUCCESSFULLYLCALIASuT������%�C����D�T����-��T����-���n�T����a��T����a���UOTHISFORMOLETREESELECTEDITEMCMDNEWCHILDENABLED
CMDDELETENODE@�%�C��
MS Sans Serif���$�
�!C��
MS Sans Serif���$��!C��
MS Sans Serif���$��!C��
MS Sans Serif���$�����!��C�fontname�Tahoma�������(��C�fontname�
MS Sans Serif�������C�fontsize�����,%�C�THIS.oleTreeb�O�	C�����9�B�-���UTHISSETALLOLETREE������
H����������.��������O��C�8The table is in use and could not be opened exclusively.��Error�x��T���-��2���$��CCC�Z�C�XCE��Error�x��T���-���UNERRORCMETHODNLINETHISFORMOPENEDSUCCESSFULLY
�����UTHISC_SOLUTIONS1SAVEHELP9%%�C�THIS.c_solutions1b�O��2�
������UTHISC_SOLUTIONS1RESTOREHELPnewkey,��refreshcombo���verifytablestructure6��opendbf���checkbuttons��Init���Error/��ActivateF��
Deactivatex��1!�2��A3Qh�q��QFqAAr2��bqA���AA��5!�A2d	��A��qA2��!���A�A2�2Q�A1o�
J@
^�,)��L2��	V<�	rfG��uI�x)�	acnextkey
cdbfname
openedsuccessfully Set to .F. if a dbf couldn't be opened
*newkey Returns a new key for the new node.
*refreshcombo 
*verifytablestructure checks to make sure the table has the necessary fields for storing or restoring an outline.
*opendbf 
*checkbuttons Enabled/Disables approprate buttons based on item selected in treeview.
comboboxcombobox	cboParentForm1�FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
RowSource = ""
Value = 0
ControlSource = ""
Height = 23
Left = 236
Style = 2
TabIndex = 10
Top = 267
Width = 242
Name = "cboParent"
�PROCEDURE InteractiveChange
THISFORM.oleTree.Nodes(THIS.Value).Selected = .T.
THISFORM.checkButtons
ENDPROC
PROCEDURE GotFocus
THISFORM.RefreshCombo
THISFORM.checkButtons
ENDPROC
��� nn_L%��U*T���������a��
����UTHISFORMOLETREENODESTHISVALUESELECTEDCHECKBUTTONS
����
����UTHISFORMREFRESHCOMBOCHECKBUTTONSInteractiveChange,��GotFocus���1��2��1e��)nlabellabelLabel1Form1�AutoSize = .T.
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
BackStyle = 0
Caption = "Select n\<ode:"
Height = 15
Left = 170
Top = 271
Width = 62
TabIndex = 9
Name = "Label1"

commandbutton
commandbutton
cmdNewNodeForm1�Top = 79
Left = 486
Height = 23
Width = 72
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Caption = "\<New Root"
TabIndex = 2
Name = "cmdNewNode"
�PROCEDURE Click
#DEFINE TXT_LOC "Click to edit text"
o = THISFORM.oleTree
o.Nodes.Add(,1,THISFORM.NewKey(),TXT_LOC,0)

ENDPROC
�� sN%����UFT������3��C�C���Click to edit text������UOTHISFORMOLETREENODESADDNEWKEYClick,��112z)
commandbutton
commandbutton
cmdDeleteNodeForm1�Top = 136
Left = 486
Height = 23
Width = 72
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Caption = "\<Delete"
Enabled = .F.
TabIndex = 4
Name = "cmdDeleteNode"
�PROCEDURE Click
o = THISFORM.oleTree
IF !ISNULL(o.SelectedItem)
	o.Nodes.Remove(o.SelectedItem.Key)
ENDIF
THISFORM.checkButtons
ENDPROC
B�� ))��%����UMT������%�C���
��<���C���������
����UOTHISFORMOLETREESELECTEDITEMNODESREMOVEKEYCHECKBUTTONSClick,��11�A�1�))
commandbutton
commandbutton
cmdLoadDBFForm1�Top = 238
Left = 486
Height = 23
Width = 72
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Caption = "\<Load DBF..."
TabIndex = 7
Name = "cmdLoadDBF"
�PROCEDURE Click
LOCAL lcOldAlias, laFields

lcOldAlias = ALIAS()
lcDBFName = GETFILE('dbf')
IF EMPTY(m.lcDBFName)
	RETURN
ENDIF
IF THISFORM.OpenDBF(lcDBFName)
	IF !THISFORM.VerifyTableStructure()
		RETURN
	ENDIF
	
	* Fill the TreeView control with values in the table.
	*----------------------------------------------------
	o = THISFORM.oleTree.Nodes
	o.Clear
	
	SCAN
		IF ALLTRIM(parent) = '0_'
			o.add(,1,ALLTRIM(key),ALLTRIM(text),0)
		ELSE
			o.add(ALLTRIM(parent),4,ALLTRIM(key), ALLTRIM(text),0)
		ENDIF
		THISFORM.cNextKey = ALLTRIM(STR(VAL(key) + 1) + "_")
	ENDSCAN
	USE
	IF !EMPTY(lcOldAlias)
		SELECT (lcOldAlias)
	ENDIF
	
ENDIF
THISFORM.checkButtons
ENDPROC
��� ��X�%X �UM����T��C��T��C�dbf���%�C�
����>�B��%�C�����<�%�C��
��m�B��T�������
���	�~��%�C�
��0_������C�C��C�
���������"��CC�
��C��C�
�������T���CCC�g�Z�_����Q�%�C��
��8�
F������
����U
LCOLDALIASLAFIELDS	LCDBFNAMETHISFORMOPENDBFVERIFYTABLESTRUCTUREOOLETREENODESCLEARPARENTADDKEYTEXTCNEXTKEYCHECKBUTTONSClick,��1��!AAQ!AA4��Q��!A�AA�AB�1�)�
commandbutton
commandbutton
cmdSaveDBFForm1�Top = 209
Left = 486
Height = 23
Width = 72
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Caption = "\<Save DBF..."
TabIndex = 6
Name = "cmdSaveDBF"
_PROCEDURE Click
LOCAL loNodes, lcParent, lcDBFName, lcOldAlias, lcOldSafety
#DEFINE WARNING_LOC "Continuing will destroy all data in the table and create a new table with three fields." + CHR(13) + "Do you want to continue?"
#DEFINE WARN_LOC "Warning"

lcOldAlias = ALIAS()
lcOldSafety = SET("SAFETY")
lcDBFName = GETFILE('dbf')

IF EMPTY(lcDBFName) && User chose Cancel
	RETURN
ENDIF

IF FILE(lcDBFName)
	IF THISFORM.OpenDBF(lcDBFName, .T.) AND ;
		THISFORM.VerifyTableStructure() AND ;
		MESSAGEBOX(WARNING_LOC,48+256+4,WARN_LOC) = 6
			SET SAFETY OFF
			ZAP
			SET SAFETY &lcOldSafety
	ELSE
		RETURN
	ENDIF
ELSE
	CREATE TABLE (lcDBFName) ;
		 (Key c(4), ;
		  Parent c(4), ;
		  Text c(60))
ENDIF



loNodes = THISFORM.oleTree.Nodes

FOR i = 1 TO loNodes.Count
	IF ISNULL(loNodes.Item(i).Parent)
		lcParent = "0_" && Root
	ELSE
		lcParent = loNodes.Item(i).Parent.Key
	ENDIF
	INSERT INTO (lcDBFName) VALUES ;
		(loNodes.Item(i).Key, ;
		 lcParent, ;
		 loNodes.Item(i).Text)
ENDFOR
USE
IF !EMPTY(lcOldAlias)
	SELECT (lcOldAlias)
ENDIF
THISFORM.checkButtons
ENDPROC
�� ���
%V�"e�U��������T��C��T��C�SAFETYv��T��C�dbf���%�C����]�B��%�C�0��[��%�C�a���C��	�C�WContinuing will destroy all data in the table and create a new table with three fields.C�
 �Do you want to continue?�4�Warning�x�	��K�G.�S�SET SAFETY &lcOldSafety
�W�B�����9h1�����C����	�C����
�C��<���T���������
���(�����R�%�CC�
���	����T���0_����T��C�
���	����5r������C�
��������C�
���
����Q�%�C��
��t�
F�����
����ULONODESLCPARENT	LCDBFNAME
LCOLDALIASLCOLDSAFETYTHISFORMOPENDBFVERIFYTABLESTRUCTUREKEYPARENTTEXTOLETREENODESICOUNTITEMCHECKBUTTONSClick,��1q�Q!�AA�caA��AA��A4�����ATAA�A�1T)�
commandbutton
commandbuttoncmdClearForm1�Top = 180
Left = 486
Height = 23
Width = 72
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Caption = "Clea\<r"
TabIndex = 5
Name = "cmdClear"
QPROCEDURE Click

THISFORM.oleTree.Nodes.Clear
THISFORM.checkButtons
ENDPROC
��� ��F:%|���U������
����UTHISFORMOLETREENODESCLEARCHECKBUTTONSClick,��1�1F)�c_solutions..\solution.vcxcustomC_solutions1Form1FTop = 273
Left = 47
Height = 18
Width = 25
Name = "C_solutions1"
behindscenes..\solution.vcx
commandbutton
Behindscenes1Form1<Top = 267
Left = 13
TabIndex = 8
Name = "Behindscenes1"
shapeshapeShape2Form1bTop = 13
Left = 11
Height = 56
Width = 548
BackStyle = 0
SpecialEffect = 0
Name = "Shape2"
labellabelLabel3Form1�FontName = "MS Sans Serif"
FontSize = 8
WordWrap = .T.
Caption = "The Treeview control is used to display an Explorer-like interface.  Click New Root to add a new item to the treeview control.  Click New Child to add a child item to the selected node.  You can Click Save DBF to save the nodes.to a DBF file."
Height = 40
Left = 21
Top = 24
Width = 529
TabIndex = 0
Name = "Label3"
labellabelLabel4Form1�AutoSize = .T.
FontName = "MS Sans Serif"
FontSize = 8
Caption = " Instructions "
Height = 15
Left = 19
Top = 7
Width = 62
TabIndex = 0
Name = "Label4"
cmdclose..\solution.vcx
commandbutton	Cmdclose1Form1:Top = 267
Left = 486
TabIndex = 11
Name = "Cmdclose1"

commandbutton
commandbuttoncmdNewChildForm1�Top = 107
Left = 486
Height = 23
Width = 72
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Caption = "New \<Child"
Enabled = .F.
TabIndex = 3
Name = "cmdNewChild"
�PROCEDURE Click
#DEFINE TXT_LOC "Click to edit text"
o = THISFORM.oleTree
IF !ISNULL(o.SelectedItem) THEN
	o.Nodes.Add(o.SelectedItem.Key, 4, THISFORM.NewKey(), TXT_LOC,0)
ENDIF

ENDPROC
O�� 66�\%����UeT������%�C���
��^�;��C����C���Click to edit text�������UOTHISFORMOLETREESELECTEDITEMNODESADDKEYNEWKEYClick,��11�A2�)6
olecontrol
olecontrololeTreeForm1PTop = 72
Left = 12
Height = 182
Width = 456
TabIndex = 1
Name = "oleTree"
PROCEDURE AfterLabelEdit
*** OLE Control Event ***
LPARAMETERS cancel, newstring
IF !ISNULL(newstring)
	THIS.SelectedItem.Text = newstring
	THISFORM.RefreshCombo
	THISFORM.cboParent.Value = THIS.SelectedItem.Index
ENDIF
ENDPROC
PROCEDURE NodeClick
*** OLE Control Event ***
LPARAMETERS node
THISFORM.RefreshCombo
THISFORM.cboParent.Value = node.Index
THISFORM.checkButtons
ENDPROC
PROCEDURE LostFocus
ON KEY LABEL F1

ENDPROC
PROCEDURE GotFocus
ON KEY LABEL F1 HELP ID _SCREEN.ActiveForm.HelpContextID
ENDPROC
��� ��wJ%�/
�UX����%�C��
��Q�T�������
����T�������	���U
CANCEL	NEWSTRINGTHISSELECTEDITEMTEXTTHISFORMREFRESHCOMBO	CBOPARENTVALUEINDEX4���
����T��������
����UNODETHISFORMREFRESHCOMBO	CBOPARENTVALUEINDEXCHECKBUTTONS{2�F1��UF19612�F1�(HELP ID _SCREEN.ActiveForm.HelpContextID�UF1AfterLabelEdit,��	NodeClick���	LostFocusc��GotFocus|��1�1��A2r�a�2�3a1��

���
)�
��ࡱ�>��	������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Root Entry��������0�DB���OleObjectData�����AccessObjSiteData&������������\ChangedProps������������X������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Alj���j��(6(!C4!/��<�j"�����Q�ͫ\$89368265E-85FE-11d1-8BE3-0000F8754DA1}Microsoft Date a�HideSelectionLAppearance	I
BorderStyle	I
E-87C4-11D1-8BE3-000i�@�\��I�R�������K�Q�DB
MS Sans Serifol, version 6.0	{FE38753A-44A3-11D1-B5B7-0000C09000C4},OLEObject = C:\WINNT\System32\mscomctl.ocx
JArial, 0, 9, 5, 15, 12, 32, 3, 0
MS Sans Serif, 0, 8, 5, 13, 11, 11, 2, 0
�DataSession = 2
Top = 3
Left = 6
Height = 297
Width = 568
DoCreate = .T.
Caption = "Add and Remove Items in a Treeview Control"
MaxButton = .F.
WindowState = 0
HelpContextID = 1231535
cnextkey = 1_
cdbfname =
Name = "Form1"