Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Activecontrol questoin
Message
De
21/02/2002 05:18:35
 
 
À
21/02/2002 05:09:41
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00622925
Message ID:
00623025
Vues:
29
This message has been marked as the solution to the initial question of the thread.
>>Hi,
>>
>>I am trying to create a function that I am going to put in the refresh method of several objects on my form. However the function should only run when the focus is on a particular object. I would like to do something like "if this.focus = .t. then do...". How can I determine if the focus is on a current object?
>>
>>N

Correction below ( last line of (2) )

Nancy,


(1) add a method to your form class: GetActiveControl()
lparameters	DoNotGoDownIfGrid

local	_ActiveControl, _ActiveColumn, i, x

if( type('thisform.ActiveControl') == T_UNDEFINED )
	return .Null.
else
	_ActiveControl = thisform.ActiveControl
endif

if( !(type('_ActiveControl') == T_OBJECT ) )
	suspend
endif

if( !DoNotGoDownIfGrid and (Proper(_ActiveControl.BaseClass) == 'Grid') )
	_ActiveColumn = _ActiveControl.ActiveColumn
	
	if( !empty(_ActiveColumn) )
		for i = 1 to _ActiveControl.ColumnCount
				x = _ActiveControl.Columns[i]
			if( x.ColumnOrder == _ActiveColumn )
				exit
			endif
		endfor
		for i = 1 to x.ControlCount
			if ( x.Controls[i].Name == x.CurrentControl )
				_ActiveControl	= x.Controls[i]
				exit
			endif
		endfor
	endif
endif

return _ActiveControl
(2) add a method to the form's class or write an udf
IsActiveControl()
lparameters Obj

local ac
ac = thisform.GetActiveControl()

if( !isnull(ac) )
    if( compobj(ac, Obj) )
       return .t.
    endif
endif
return .F.
(3) Does this object have the focus ?
if( thisform.IsActiveControl(this) )
    && yes
endif
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform