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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Project Hook Class?? 2

Status
Not open for further replies.

FattyKat

Programmer
Feb 21, 2002
32
IN
Whats a Project Hook Class?
How does it help me in my project?
How do i make it work for me?
[Poke]
 
A project hook class, is a class that helps you use the project manager, keeps track when you add and remove files from the project manager.
It's the class that manages your project.
 
Now how do i create one, and how do I make use of it subsequently?Give me an example if possible.
[poke]
 
A project hook class is more used by VFP and the project manager, than something you would use in an application. What are you looking for? An application library, a session class?

 
Since I brought up the project class I guess I should help with some details (they were a mystery to me before I figured out how to use them!). First you'll need to be working in VFP 6.0 or higher (VFP 3/5 don't have them).

At the Menu, choose File -> New -> Class -> click on New File. Provide a Class Name: (e.g. pj), Based On: ProjectHook (it's one of the VFP foundation classes), Store In: (e.g <project path>pj.vcx), and for now just close and save it.

Now go open the project that you want to associate this with. Menu -> Project -> Project Info ... . Check the Project Class checkbox, and select the Project Hook Class (e.g. Pj in Pj). You now are all done, except that it doesn't do anything! That's is other than creating a projecthook object each time you open this project, and like all objects, it has some useful properties and methods.

To see these work, you'll first need to close the project, because like classes on a form, you can't modify them when they are open. Next re-open the Projecthook class and take a look at the PEMs available. I've found the INIT() useful for opening up a given form or program (e.g. MODIFY FORM mainform.scx NOWAIT). The one I feel is most important is the BeforeBuild() Event. I've put code to update development audit trails - great for justifying billing, updating source control environments, changing file attributes, clearing out report/label default printer info, copy files around, etc.. You may even need to create and set some user defined properties to &quot;pass&quot; information between the BeforeBuild() code and the AfterBuild() code (e.g. Which files you reset the Read-only attribute on, so you can reset it back!)

In the project hook methods you can access all the properties and methods of project object also, so you can check on the files, last updated times, etc. on all the other pieces of the project.

For more info on the Project Object Model or the Projecthook, see the VFP help file, and/or go to the MS Knowledge Base Articles at and read:

Q191272 - Howto: A Brief Exploration of the Project Object Model
Q192105 - Howto: Programmatically Creating and Building a Project

Q192330 - Howto: Using the ProjectHook Class to Create a Generic Project
Q192578 - Howto: Creating and Customizing a ProjectHook Class
Q192343 - Howto: Associating the Default ProjectHook Class to a Project

And of course when you have specific questions, come back here to Tek-Tips and ask!

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top