Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subclassing base classes
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00826518
Message ID:
00826524
Views:
19
This message has been marked as a message which has helped to the initial question of the thread.
>I just recently learned of the advantages of subclassing the base classes, and we're starting to use them. One problem that I have however is the fact that, for example, if you have code in the INIT() of the class, but then put code in the INIT() of the instance of the object, the code of the class won't fire unless you have DO DEFAULT in there. Is there any way around this? I mean otherwise, everytime I use this class, I have to explicitly remember to put DO DEFAULT if I want to add code to the INIT().
>
>For example, in my textbox subclass (and many others), I call a function called GetColorPreference() in the INIT(). I use that function get the color settings of whoever is logged in and set the appropriate BackColor, Forecolor, etc properties. Well, if I'm using this class, and somewhere down the line, I have the need to put code in the INIT() of the actual instance of the object, I have to remember to put DO DEFAULT.
>
>Please help, or am I just going about this all wrong?
>
>Thanks,
>

Nirav,
Unfortunately, that's just the way things are.

You can alleviate the issue slightly by adding Hook methods and method calls to the Init of your subclass. What I mean by hook methods is abstract/empty methods within the subclass. These empty methods are called from various points in the Init method. If a user wants to add code to the Init process they can add code to the hook methods in their subclass and they never have to modify the Init method itself. However, if they do, they will have to remember to add the DODEFAULT.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform