EnumChildWindows

Post Reply
Natter
Posts: 524
Joined: Mon May 14, 2007 9:49 am

EnumChildWindows

Post by Natter »

Hi, all !
Where I can find examples with function API EnumChildWindows() using ? I finded examplest on VB/Delphi/C. But ! can't write it on FWH.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

You can use this code to access all child windows:

Code: Select all

#define GW_CHILD      5 
#define GW_HWNDNEXT   2 

function ProcessChilds( oDlg ) 

   local hCtrl := GetWindow( oDlg:hWnd, GW_CHILD ) 

   ... your code ...

   while hCtrl != 0 
      hCtrl = GetWindow( hCtrl, GW_HWNDNEXT ) 
      ... your code ...
   end 

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Natter
Posts: 524
Joined: Mon May 14, 2007 9:49 am

Post by Natter »

Function GetWindow( hCtrl, GW_HWNDNEXT ) not find MDI windows . For this I to used FindWindowEx. Then I want get handles of controls on this MDI window by function GetWindow, but can't do it. I read that can to use EnumChildWindows for it.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

We are going to implement it :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Natter
Posts: 524
Joined: Mon May 14, 2007 9:49 am

Post by Natter »

Thank, Antonio ! It's work
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Here you have it:

Code: Select all

// (c) FiveTech Software, 2008

#include "FiveWin.ch"

function Main()

   local oDlg

   DEFINE DIALOG oDlg TITLE "Test"

   @ 2, 2 BUTTON "Enum" ;
      ACTION EnumChildWindows( oDlg:hWnd,;
             { | hChild, nLParam | MsgInfo( GetClassName( hChild ) ), .T. },; // .T. means continue
             0 ) // optional supplied value

   @ 2, 8 BUTTON "Another"

   ACTIVATE DIALOG oDlg CENTERED

return nil

#pragma BEGINDUMP 

#include <hbapi.h>
#include <hbapiitm.h>
#include <windows.h>

void hb_evalBlock( PHB_ITEM pCodeBlock, ... );

static PHB_ITEM pCodeBlock = NULL;

BOOL CALLBACK static EnumChildProc( HWND hWnd, LPARAM lParam )
{
	 PHB_ITEM pHWnd  = hb_itemPutNL( NULL, ( LONG ) hWnd );
	 PHB_ITEM pParam = hb_itemPutNL( NULL, ( LONG ) lParam );
	 
	 if( pCodeBlock )
      hb_evalBlock( pCodeBlock, pHWnd, pParam, 0 );
      
   hb_itemRelease( pHWnd );
   hb_itemRelease( pParam );   
      
   return hb_parl( -1 );   	
}	

HB_FUNC( ENUMCHILDWINDOWS )
{
   HWND hWnd = ( HWND ) hb_parnl( 1 );
   LPARAM lParam = ( LPARAM ) hb_parnl( 3 );
   
   pCodeBlock = hb_param( 2, HB_IT_BLOCK );
   hb_retl( EnumChildWindows( hWnd, EnumChildProc, lParam ) );
   pCodeBlock = NULL;
}   

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply