Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ThisForm.ActiveControl Returns Not An Object
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00510492
Message ID:
00510583
Views:
15
>Following on Larry's coattails,
>
>>>IF TYPE("ThisForm.ActiveControl.Name") = "C" will return .T. if ActiveControl is a valid object with a Name property. Do not use Vartype() for this as it is not robust enough for the checking and it will throw an error.
>
>The same can be done with variables.>>
>
>
>While
>TYPE("ThisForm.ActiveControl.Name") = "C"
>
>is functionally similar to
>TYPE("ThisForm.ActiveControl") = "O"
>
>testing agains the .Name property of an object is more robust than testing against the object itself. It sure looks weird though.
>
>Regards,
>Thom C.

The robustness comes in when TYPE() returns "O" for an object that was created and then NULLed. The variable/property is still an object but no longer available.

While it isn't relevant to discussions about ActiveControl because that is a Read-Only property and controlled internally by VFP, it is relevant in the following example:
oform = createobject("form")
With oform
   .AddProperty("oWord")
   .oWord = createobject("word.application")
   ? type(".oWord")       && returns O
   ? type(".oWord.Name")  && returns C
   .oWord.Quit
   ? type(".oWord")       && still returns O
   ? type(".oWord.Name")  && returns U
Endwith
Jim Booth and Drew Speedie use this technique all the time and preach its merits. Others may have as well.
Larry Miller
MCSD
LWMiller3@verizon.net

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

Click here to load this message in the networking platform