Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get ActiveRow,ActiveColumn,RelativeRow,RelativeColumn
Message
From
19/06/2003 06:51:04
 
 
To
19/06/2003 06:12:37
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00801629
Message ID:
00801658
Views:
17
>Hi Fabio,
>There is no solution without setfocus, since your properties are only available if the grid has focus. (ACTIVE* need to be active? ::) )
>So you need to set focus to the grid, read your props and reset focus.
>The biggest problem is to store and restore actual object. Since there are some traps I will give you an example.
>
>
>LOCAL;
> loActiveControl
>
>THISFORM.LOCKSCREEN = .T.
>*Check if a Control is focused and if it could receive focus again
>IF TYPE('THISFORM.ACTIVECONTROL')='O';
>  AND !ISNULL(THISFORM.ACTIVECONTROL);
>  AND PEMSTATUS(THISFORM.ACTIVECONTROL,'SETFOCUS',5) THEN
> loActiveControl = THISFORM.ACTIVECONTROL
>ELSE &&TYPE('.ACTIVECONTROL' ...
> loActiveControl = NULL
>ENDIF &&TYPE('.ACTIVECONTROL' ...
>
>*YourGrid.SETFOCUS()
>*Get your properties
>
>*Re - Focus last Object
>IF !ISNULL(loActiveControl) THEN
> loActiveControl.SETFOCUS()
>ENDIF &&!ISNULL(loActiveControl)
>THISFORM.LOCKSCREEN = .F.
>
>
>HTH
>Agnes
>>Thanks Gregory.
>>
>>I need a solution without grid focus.
>>
>>Fabio

Hi Agnes,

For what it is worth I include a form method: GetActiveControl()

When a grid has the focus, it returns the actual control within the grid unless called with a parameter TRUE
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 ) )
	assert FALSE
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
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform