Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to detect that control is added in run-time
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00418065
Message ID:
00418528
Views:
20
>>One idea...
>>At the end of your base form's Init() set a custom property lInitFinished = .T.
>>Default this property to .F.
>>In each control's base class (i.e., your base classes) check for form.lInitFinished = .T. - if it is, it was added at run time.

PMFJI, but I would move this setting to the beginning of the form's Init event for the following reason.

Contained controls execute their Init before the form. By the time the Init of the form fires, the Init of all the controls added at design time have already fired. If you wait until the end of the Init to set the flag and during the Init of the form perform an AddObject/NewObject, the control is added at run time (IMO) but its Init will think it was added at design time because the flag hasn't been set yet.

Also, with this approach, you need to remember to add a DODEFAULT() or MyParentClass::Init() at the top of Init methods you modify at the subclass or instance level to make sure the technique behaves in the desired manner.

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