Page 1 of 1

Dynamically adjusting a get field width in a folder

Posted: Mon Jan 07, 2008 3:19 am
by hua
For gets on a regular dialog box, I use the following to change their width:

Code: Select all

activate dialog oDlg on init ChgGetsWid(oDlg)
How to specify on init for a folder's page?

TIA

Posted: Mon Jan 07, 2008 5:50 am
by James Bott
Have you tried oFolder:bInit?

James

Posted: Mon Jan 07, 2008 8:50 am
by StefanHaupt
Hua, James,

the bInit is not executed for the dialogs.

You have to change the method Default(), where the the dialogs are activated and add your own bInit to the standard init.

Posted: Mon Jan 07, 2008 9:03 am
by James Bott
Stefan,

>the bInit is not executed for the dialogs.

I'm not sure what you mean. Can't you just do something like:

activate dialog oDlg on init oFolder:bInit

Are you saying that oDlg:bInit never gets eval'd?

James

Posted: Mon Jan 07, 2008 12:19 pm
by StefanHaupt
James,

in the folder class for every page a dialog is created (see Method New() or Redefine() ). These dialogs are activated in the method Default().

Code: Select all

for nLen = 1 to Len( ::aDialogs )
      oDlg = ::aDialogs[ nLen ] 
.....
ACTIVATE DIALOG oDlg NOWAIT ; 
                  ON INIT oDlg:Move( nHeight - 1, 1 ) ; 
                  VALID .f.                // to avoid exiting pressing Esc !!! 
......
As you see there is no self-defined bInit (e.g. oFld:bInit) executed.

A possible solution could be (not tested !)

Code: Select all

ACTIVATE DIALOG oDlg NOWAIT ; 
                  ON INIT (oDlg:Move( nHeight - 1, 1 ), IIF(::bInit!=nil,Eval(bInit),) ) ; 
                  VALID .f.                // to avoid exiting pressing Esc !!! 

Posted: Mon Jan 07, 2008 12:43 pm
by Antonio Linares
As Stefan explains, the ON INIT of the folder dialogs is being used, so it replaces a previous existing bInit:

oFolder:aDialogs[ n ]:bInit = { || ... code ... }

so the Stefan solution is right. I suggest it this way:

Code: Select all

ACTIVATE DIALOG oDlg NOWAIT ; 
        ON INIT ( oDlg:Move( nHeight - 1, 1 ),;
        If( oDlg:bInit != nil, Eval( oDlg:bInit, oDlg ),) ) ; 
        VALID .F.

Posted: Tue Jan 08, 2008 8:47 am
by StefanHaupt
Yes, you are right :D

So every page of the folder can have it´s own bInit.

Posted: Wed Jan 09, 2008 2:14 am
by hua
James, Stefan, Antonio,
Thanks for the input :) . Will give it a try later on