How to get array of Controls

How to get array of Controls

Postby Rick Lipkin » Thu Jun 14, 2018 5: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: Select all  Expand view  RUN


oPersonal:aControls[ 1 ]:SetSize( nWidth - 20,  nHeight - 50 ) // folder

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

 


Image


Any help would be appreciated ..

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: How to get array of Controls

Postby cnavarro » Thu Jun 14, 2018 5:24 pm

Rick

Code: Select all  Expand view  RUN


   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
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: How to get array of Controls

Postby Rick Lipkin » Thu Jun 14, 2018 5:37 pm

Cristobal

You code did not work .. on resize ..

Here is the code:
Code: Select all  Expand view  RUN


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)

 
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: How to get array of Controls

Postby nageswaragunupudi » Fri Jun 15, 2018 4: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: Select all  Expand view  RUN
#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
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 53 guests