FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to get array of Controls
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
How to get array of Controls
Posted: Thu Jun 14, 2018 05:19 PM
To All

I have a Folder ( oFld ) that is laying on top of a mdichild .. in that folder is a dialog ( oPersonal ) with buttons and Txbrowse ... I am trying to get the array of controls on the dialog oPersonal.

I used to be able to use xbrowse( oPersonal:aControls ) .. and with FWH 1707 ( kinda old ) I do not see the array list of all the controls .. I am looking for the array element for txbrowse within the oPersonal dialog .. so I can use it to manually move the xBrowse opbect on a resize event .. I have tried several possible oPersonal:acontrols[2],[3] .. with no joy.

Code (fw): Select all Collapse
oPersonal:aControls[ 1 ]:SetSize( nWidth - 20,  nHeight - 50 ) // folder

oFld:aDialogs[1]:aControls[1]:SetSize( nWidth - 28 , nHeight - 300 )   // window frame





Any help would be appreciated ..

Rick Lipkin
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: How to get array of Controls
Posted: Thu Jun 14, 2018 05:24 PM
Rick

Code (fw): Select all Collapse
   local aCtrls    := {}

   AEVal( oFld:aDialogs[1]:aControls, { | a | AAdd( aCtrls, a ) } )
// or
   AEVal( oFld:aDialogs[1]:aControls, { | a | a:SetSize( nWidth - 28 , nHeight - 300 ) } )
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: How to get array of Controls
Posted: Thu Jun 14, 2018 05:37 PM
Cristobal

You code did not work .. on resize ..

Here is the code:
Code (fw): Select all Collapse
ACTIVATE WINDOW oWndChildA ;
         ON INIT (oWndChildA:bResized := {|| _ReSizeUm( oPersonal,oWndChildA,oLbxA,oFld ) }, ;
           oPersonal:refresh(.t.));
         VALID ( IIF( !lOK, _CloseRes(.T.,oFontB, oRsPort, oLbxA, @lOk, oWndChildA ),.F. ))


//-----------------------------------
Static Func _ReSizeUm( oPersonal, oWndChildA,oLbxA,oFld )

oPersonal:SetSize( oWndChildA:nWidth, oWndChildA:nHeight, .t. ) // frame and dialog link

// dialog controls
oPersonal:bResized = { | nSizeType, nWidth, nHeight | _ResizeControls( nSizeType, nWidth, nHeight, oPersonal,oFld )  }

Return(nil)

//-------------------------
Static Func _ResizeControls( nSizeType, nWidth, nHeight, oPersonal, oFld )

Local aCtrls := {}

AEVal( oFld:aDialogs[1]:aControls, { | a | AAdd( aCtrls, a ) } )   // nothing happens

*xbrowse( oPersonal:aControls )
*xbrowse( oFld:aDialogs[1]:aControls )


if nSizeType = 0 //SIZE_MAXIMIZED
                                         // 20          // 90 50
   oPersonal:aControls[ 1 ]:SetSize( nWidth - 20,  nHeight - 50 ) // folder

   // 50           // 340
   oFld:aDialogs[1]:aControls[1]:SetSize( nWidth - 28 , nHeight - 300 )   // window frame

*   oFld:aDialogs[1]:aControls[2]:SetSize( nWidth - 28 , nHeight - 300 )   // xbrowse  ????????


endif

Return(nil)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: How to get array of Controls
Posted: Fri Jun 15, 2018 04:33 AM
It is much simpler if you want to resize folder and xbrowse only. We can use the built-in feature of xbrowse to resize when the parent is resized. Please try this sample as it is. Copy this sample to fwh\samples folder.

Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   local oWnd, oBar

   DEFINE WINDOW oWnd MDI
   DEFINE BUTTONBAR oBar OF oWnd SIZE 100,32 2007
   DEFINE BUTTON OF oBar PROMPT "Child Browse" CENTER ACTION ChildBrowse()
   ACTIVATE WINDOW oWnd MAXIMIZED

return nil

//----------------------------------------------------------------------------//

static function ChildBrowse()

   local oWnd, oFld, oBar, oBrw, cAlias, oFont

   USE CUSTOMER NEW SHARED ALIAS ( cAlias := cGetNewAlias( "CUST" ) )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,14
   DEFINE WINDOW oWnd MDICHILD OF WndMain() TITLE "Title"
   oWnd:SetFont( oFont )

   DEFINE BUTTONBAR oBar OF oWnd 2007
   SET MESSAGE OF oWnd TO "" 2007

   @ 0,0 FOLDEREX oFld SIZE 1000,900 PIXEL OF oWnd PROMPTS "Personal", "Second" BOTTOM ADJUST OPTION 1

   @ 20, 60 XBROWSE oBrw SIZE -28,-300 PIXEL OF oFld:aDialogs[ 1 ] ;
      DATASOURCE cAlias AUTOCOLS CELL LINES NOBORDER

   oBrw:CreateFromCode()

   oWnd:aMinMaxInfo := { nil, nil, nil, nil, 200, 500, nil, nil }

   oWnd:bPostEnd  := { ||  ( cAlias )->( DBCLOSEAREA() ), ;
                           oFont:End() }

   ACTIVATE WINDOW oWnd

return nil

//----------------------------------------------------------------------------//
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion