Decorating with This_Access
* Set this constant to an existing project you have somewhere
#Define PROJECT_FILE "MyProjectFile.pjx"
Local oMyProject As MyProject
* Create an instance of our project class passing the project file to the Init method.
oMyProject = NewObject("MyProject", "", "", PROJECT_FILE)
* Display some project properties to the desktop
? oMyProject.HomeDir
? oMyProject.Files.Count
* Call our Close method so we can execute our code before and after the project closes.
oMyProject.Close()
Return
Define Class MyProject As Custom
IFoxProject = Null
Function Init(lpcProjectFile As String)
* Check if project is open
If Type([Application.Projects("] + lpcProjectFile + [")]) = "U"
* Open project
Modify Project (lpcProjectFile) NoWait Save NoShow
EndIf
* Set a reference to the project object
This.IFoxProject = Application.Projects(lpcProjectFile)
EndFunc
Function This_Access(lpcMemberName As String)
* Check if we wish to handle this or just pass it on to the IFoxProject object
If Not InList(lpcMemberName, "ifoxproject", "build", "close")
* Check we have a reference to the project object
If Not IsNull(This.IFoxProject)
Return This.IFoxProject
EndIf
EndIf
* Return the reference to this class
Return This
EndFunc
Function Close()
*** Write code or raise a before close event here ***
This.IFoxProject.Close()
*** Write code or raise an after close event here ***
EndFunc
Function Build( lpcOutputName As String, lpnBuildAction As Integer,;
lpbRebuildAll As Boolean, lpbShowErrors As Boolean,;
lpbBuildNewGUIDs As Boolean)
*** Write code or raise a before build event here ***
This.IFoxProject.Build( lpcOutputName As String, lpnBuildAction As Integer,;
lpbRebuildAll As Boolean, lpbShowErrors As Boolean,;
lpbBuildNewGUIDs As Boolean)
*** Write code or raise an after build event here ***
EndFunc
EndDefine
