Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting rid of unwanted CUSTOM props in PRG-based classe
Message
 
 
To
10/12/2001 15:47:59
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00592351
Message ID:
00594888
Views:
21
Hi Stefan,

It's interesting tip. You could consider to add it to the UT FAQ section.

>Today I tried to use the Locals Window and the Watch Window to debug a class I was writing but the protected properties did not show up even though they were in scope (I was stepping through one of the methods). Naturally I was somewhat peeved but then found a useful application for this behaviour ...
>
>When you DEFINE CLASS CFoo AS CUSTOM then there is a lot of baggage that serves no useful purpose - what would a non-visual class want with .Width or .Height properties, especially as you cannot derive a visual class from it? A bit of preprocessor magic can help you get rid of that stuff:
>
>
#if "03.00.00.0" $ version()
>#  define hidden protected
>#endif
>
>#define HIDE_EXTRANEOUS_CUSTOM_PROPERTIES ;
>   hidden baseclass, controlcount, controls, height, helpcontextid, left, name;
>      , objects, parent, parentclass, picture, tag, top, whatsthishelpid, width
>
>* ...
>
>define class CFoo as custom
>   HIDE_EXTRANEOUS_CUSTOM_PROPERTIES
>   c_ThisProp = "meow"
>   c_ThatProp = "purr"
>   * ...
>enddefine
>
>Of course, the class itself still sees the extra stuff so the proper solution (post-3.0 Foxen only) would be to introduce a new CCleanCustom base class whose only purpose is to extinguish the extra properties, and to derive the custom classes from that. You also might want to spare .Parent and .Name if you .AddObject instances of your class to others and want the object to be able to detach itself via this.Parent.RemoveObject(this.Name).
>
>Have fun ...
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform