ProjectHook Property

This property gives you an object reference to the current project hook for a project. Amazingly, you can change it on the fly.

Usage

prjProject.ProjectHook = phkProjectHook
phkProjectHook = prjProject.ProjectHook
A project hook is a VFP object associated with a project that lets you jump in and exercise some control as the project is processed. When a project is open, this property points you to its current project hook. We recommend you return the favor and give your project hooks a reference to their projects.We were somewhat stunned to discover that you can change this property at runtime. Just create a project hook object and attach it. (In fact, the same project hook instance can be attached to more than one project.) The project hook stays attached only as long as the project is open, though—it doesn't become the default for the project. While we don't see ourselves taking advantage of this capability often, we can imagine that there might be some unusual tasks for which we might want to create a special project hook class, then open a series of projects in sequence, hook them up and do whatever it is. This is also the only way to attach a project hook to a project when that project hook is defined in code, rather than visually.There are kinks you will need to look out for if you attach project hooks this way. Because the object needs to be instantiated before it's attached to the project, the Init code can't make assumptions that "its" project is _VFP.ActiveProject, or even that there's a project open. Overall, switching hooks on the fly is something we will probably leave to the third-party vendors and builders. But we can see some the possibility of some cool stuff possible this way.

Example

* Attach a project hook to the active project
_VFP.ActiveProject.ProjectHook = NewObject("phkHook","MyLibr")

See Also

Project, ProjectHook, ProjectHookClass, ProjectHookLibrary


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .