Please Antonio Linares,
FindObject( GetActivateWindow() ), not found the Handle in GetAllWin(), when Handle active Window belong ClassName = "#32770"
Always return correctly, when the handle is control with focus, FindObject( GetFocus()).
--------------------------------------------------------------------------
Montei uma rotina de propósito geral, onde pesquiso o handle do controle informado(ou ativo), e retorno o objeto associado.
Caso eu procure o controle que esta em foco, sempre encontra corretamente.
- Code: Select all Expand view
/****************************************************
Retorna o objeto associado ao Handle informado.
Return Object associate to Handle argument.
****************************************************/
function FindObject( nHandle ) // => oControl
TypeU nHandle Def GetFocus()
return FindObj( nHandle, GetAllWin() )
/****************************************************
Faz a pesquisa recursiva
Find recursive
****************************************************/
static function FindObj( nHandle, oSource ) // oControl
local oControl
if ValTypeA(oSource)
AEVAL( oSource, {|o,x| x:=FindObj(nHandle,o), oControl:=if(x=nil,oControl,x) })
elseif ValTypeO(oSource)
if oSource:hWnd = nHandle
oControl:=oSource
elseif 'DIALOG' $ oSource:ClassName .or. ;
'WINDOW' $ oSource:ClassName .or. ;
'#32770' $ oSource:ClassName .or. ;
'MDICHILD' $ oSource:ClassName .or. ;
'MDIFRAME' $ oSource:ClassName
AEVAL( oSource:aControls, {|o,x| x:=FindObj(nHandle,o), oControl:=if(x=nil,oControl,x) })
elseif 'FOLDER' $ oSource:ClassName .or. ;
'PAGES' $ oSource:ClassName
AEVAL( oSource:aDialogs, {|o,x| x:=FindObj(nHandle,o), oControl:=if(x=nil,oControl,x) })
endif
endif
return oControl
/****************************************************
Retorna o Objeto da janela ativa
Retorn object to Window active
****************************************************/
function WindowObject() // => oWindow
return FindObject( GetActiveWindow() )
//****************************************************