Dynamically adjusting a get field width in a folder

Post Reply
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Dynamically adjusting a get field width in a folder

Post 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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Have you tried oFolder:bInit?

James
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Post 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.
kind regards
Stefan
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Post 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 !!! 
kind regards
Stefan
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Post by StefanHaupt »

Yes, you are right :D

So every page of the folder can have it´s own bInit.
kind regards
Stefan
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Post by hua »

James, Stefan, Antonio,
Thanks for the input :) . Will give it a try later on
Post Reply