Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting a method at runtime
Message
From
09/09/1998 22:06:45
 
 
To
09/09/1998 07:09:36
Cristian Tenea
Aquila Part Prod Com
Ploiesti, Romania
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00134394
Message ID:
00134883
Views:
10
You can define a hook in the method you want to change (mousemove in this case):

do &MyHook

and set the value of MyHook to something that will execute your code. Even better, the hook may be a property of your column class (in the case you're using your own column class).

This way you can change the behavior of this method as you like at runtime, without subclassing for each new behavior. Now, I'm sure you can see that this method can be extended as far as you want and, if you use it consistently in your framework, you can have very good flexibility without having large hierarchies of classes. Being modifiable at runtime, you can use it to modify/update your apps without having to recompile everything and to ship complete new versions.

Another way to define hooks (more generic and powerful, IMHO) is to have a Hook class. All your other classes have a Hook property and all their methods call the corresponding method of the Hook object attached (if any) to the Hook property. For example, in the Click event of your classes you will have:

IF TYPE("This.Hook.Name") == "C"
*-- We have a valid hook object attached
This.Hook.Click()
ENDIF

Something similar goes for all the other methods.

Now, you can cascade/chain the hooks by adding a Hook property to your hook class, etc.

Many thanks to Steven Black for these ideas...

Vlad

>I want to change a method at runtime for a column in grid;
>At runtime I added a column to grid and want to execute something at mousemove event.
>
>Thanks.
Previous
Reply
Map
View

Click here to load this message in the networking platform