Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to detect that control is added in run-time
Message
From
20/09/2000 13:05:44
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00418065
Message ID:
00418613
Views:
22
Hi, Larry!

I figured out all these things by self, however, thanks anyway, your suggestions are correct.
However, I have a problem. This method will not work in some cases.
Example:
I have a container class in library which contains my control. In control I want to detect if it is added in design time or in run-time. When this control put on form in run-time - it wll work. THAN, when I put control into container class, it means design time. However, when I ad container in run-time, Init of control will not be able to detect that it was placed into container class in run-time.
Sure, I may make the same with container (make property and set it at init, check in init of control), however, I want to have generic approach that works for both cases without changing of each base class.

>>>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.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Reply
Map
View

Click here to load this message in the networking platform