Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with _Screen.ActiveForm.ActiveControl
Message
 
 
À
03/05/2001 15:23:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00476476
Message ID:
00503210
Vues:
40
FYI.

You can create a method of your application object (or forms manager) that returns the real ActiveForm and use this method call instead of the _Screen property. Ex.
if vartype(_Screen.ActiveForm) = "O" ;
   and pemstatus(_Screen.ActiveForm,"BaseClass",5) ;
   and upper(_Screen.ActiveForm.BaseClass) = "FORM" then
   return _Screen.ActiveForm
else
   * use a Do While Loop to cycle through the .Parent properties until you get to an object that's a form
   local lotmp
   lotmp = _Screen.ActiveForm.Parent
   do while .T.
      if isnull(lotmp);
         or upper(lotmp.BaseClass) = "FORM" then
         exit
      else
         lotmp = iif(vartype(lotmp.Parent) = "O",lotmp.Parent,NULL)
      endif
   enddo
   
   return lotmp
endif
Haven't tested this, so YMMV. It may have to be tweaked to add more error trapping.


>>>>Hi Fred,
>>>>
>>>>loActiveControl = This.GetActiveControlRef(_Screen.ActiveForm.ActiveControl)
>>>>This line is part of a save routine(write buffer) which is trying to to get the active control so I could check to determine if the user is currently in a grid. IF the user is currently in a grid then I would loop through the columns in the grid to find the active column then the active control with in that column. *!* Also This code is also in the VFP FFC _app.vcx base class (_datasession, dataflush method)
>>>>
>>>>Thank you for responding.
>>>>
>>>>Andy
>>>
>>>Since you're using it in an object of some sort, is the "this" you're refereing to on a form? If it is, try doing "thisform.ActiveControl". You may also want to check to make sure that it is an object before attempting to use it.
>>>
>>>IF TYPE("_SCREEN.ActiveForm.ActiveControl")="O" ...
>>
>>Fred,
>>
>>I have a very similar problem. My textbox is based on a class. In the WHEN method of the class I placed the following line:
>>
>>ThisForm.oCurrentObject = _SCREEN.ActiveForm.ActiveControl
>>
>>oCurrentObject is a property I created on the form. I have other code in a method that sets the focus to oCurrentObject like this:
>>
>>IF Type('ThisForm.oCurrentObject')="O"
>> ThisForm.oCurrentObject.SetFocus()
>>ENDIF
>>
>>I get the "ActiveControl is not an object" message on the class WHEN method. I have tried putting the code in the GOTFOCUS and various permutations of "ThisForm" vs "__SCREEN.Active.Form" with the same results.
>>
>>Any ideas? Thanks!
>>
>>Renoir
>
>I think you can run into this problem when there are ActiveX controls on the form. Somehow, the _SCREEN.ActiveForm ends up being the ActiveX control, not the form itself. Sorry, I don't know of a way of dealing with that as I have never seen it.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform