Page 1 of 1

Object associate Handle Window with ClassName = "#32770

Posted: Sun Feb 25, 2007 4:20 am
by ericmagaldi
Sorry my English :)

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

/**************************************************** 
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() ) 
//****************************************************

Posted: Sun Feb 25, 2007 9:20 am
by Antonio Linares
Éric,

Class "#32770" is a standard Windows Class that is used to create the dialogboxes.

FW does not include the dialogs inside the returned array from GetAllWin() because the dialogos don't get replaced theirs windows procedures, as we just store there the windows and controls that have changed their procedures.

I guess that you want to find a dialog given its window handle, right ?

Posted: Sun Feb 25, 2007 9:36 am
by ericmagaldi
Antonio Linares wrote:Éric,

Class "#32770" is a standard Windows Class that is used to create the dialogboxes.

FW does not include the dialogs inside the returned array from GetAllWin() because the dialogos don't get replaced theirs windows procedures, as we just store there the windows and controls that have changed their procedures.

I guess that you want to find a dialog given its window handle, right ?
Sim.
Dependendo da rotina, gostaria de acessar todos os controles do Dialogo atual. Como eu faço ?
/*
Yes, depend routine, need access objects all control of Dialog. How resolve ?
*/
regards.

Posted: Sun Feb 25, 2007 12:21 pm
by Antonio Linares
Éric,

Code: Select all

AEval( oDlg:aControls, { | oControl | ... } )

or

for n = 1 to Len( oDlg:aControls )
   ... oDlg:aControls[ n ] ...
next

Posted: Sun Feb 25, 2007 1:24 pm
by ericmagaldi
of course... oDlg:aControls.... :)

but, how found object of Dialogs "#32770" ? have only handle of Dialog active.

thanks !!

Posted: Sun Feb 25, 2007 8:25 pm
by Antonio Linares
Éric,

FWH does not provide yet a function to retrieve a dialog object given its window handle

Ahyhow, given any window handle you can check all its controls using GetWindow()

Code: Select all

   local hCtrl := GetWindow( hWnd, GW_CHILD ) 

   while hCtrl != 0 
      if GetClassName( hCtrl ) == "Static"  // SAY 
         ... 
      endif 
      hCtrl = GetWindow( hCtrl, GW_HWNDNEXT ) 
   end