Page 1 of 1

Button bar on dialog ?

Posted: Wed Dec 12, 2007 9:38 pm
by TimStone
Hmmmm ....

I have only used one button bar on my main program. I was toying with the idea of putting button bars on some dialogs. The manual indicates you can do this, so if I try to add

DEFINE BUTTONBAR oBar OF oDlg SIZE 60,60 2007

it should work ???? Instead I get an error indicating it can't create the dialog ...

Is this no longer a valid option, or do I need to do something else in a dialog to get it to run ?

Re: Button bar on dialog ?

Posted: Wed Dec 12, 2007 10:31 pm
by Enrico Maria Giordano
You must create the buttonbar inside the ON INIT clause.

EMG

Strange

Posted: Wed Dec 12, 2007 10:48 pm
by TimStone
So the button bar, and the buttons, would need to go in the ON INIT statement when activating the dialog ? I just tried that with a COMMAND line and the compiler doesn't like that ...

Button Bar

Posted: Thu Dec 13, 2007 12:54 am
by Colin Haig
Hi Tim

ACTIVATE DIALOG oDlg CENTERED ;
ON INIT(AddBar(oData,oLbx,nNum,oStock));
VALID(WinOpen(oMainWnd,0),lExit)

static function AddBar(oData,oLbx,nNum,oStock)
local oBar,oBtn,oBtn1,oBtn2,oBtn3,cExitTip := '',cAddTip := '',cDelTip := '',cPrintTip := '',lRecs := FALSE
if nNum == 1
cExitTip := 'Exit Department Code Screen'
cAddTip := 'Add Department Code'
cPrintTip := 'Print Department Codes'
cDelTip := 'Delete Deparment Code'
elseif nNum == 2
cExitTip := 'Exit Timesheet Code Screen'
cAddTip := 'Add TimeSheet Code'
cPrintTip := 'Print Timesheet Codes'
cDelTip := 'Delete Timesheet Code'
elseif nNum == 3
cExitTip := 'Exit Stock Codes'
cAddTip := 'Add Stock Code'
cPrintTip := 'Print Stock Codes'
cDelTip := 'Delete Stock Code'
elseif nNum == 4
cExitTip := 'Exit Store Codes'
cAddTip := 'Add Store Code'
cPrintTip := 'Print Store Codes'
cDelTip := 'Delete Store Code'
elseif nNum == 5
cExitTip := 'Exit Tasks'
cAddTip := 'Add Task'
cPrintTip := 'Print Tasks'
cDelTip := 'Delete Task'
endif
if oData:reccount() > 0
lRecs := TRUE
endif

DEFINE BUTTONBAR oBar 3DLOOK SIZE 45, 45 OF oDlg 2007

DEFINE BUTTON oBtn of oBar RESOURCE "BTN_EXIT";
FLAT ;
PROMPT "Exit" ;
ACTION(lExit := TRUE,oDlg:End());
TOOLTIP(cExitTip)

DEFINE BUTTON oBtn1 of oBar RESOURCE "PLUS";
FLAT ;
PROMPT "Add" ;
ACTION(oData:Blank(),oData:append(),oLbx:Refresh(),oLbx:SetFocus(),oLbx:GoToCol(1));
TOOLTIP(cAddTip)

DEFINE BUTTON oBtn2 of oBar RESOURCE "PRINTER";
FLAT ;
PROMPT "Print" ;
ACTION(PrntCodes(oData,nNum),oLbx:Refresh(),oLbx:SetFocus());
TOOLTIP('Print Time Data')

DEFINE BUTTON oBtn3 of oBar RESOURCE "DELETE";
FLAT ;
PROMPT "Delete" ;
ACTION(lRecs := DelRec(lRecs,nNum,oData,oStock),if(lRecs,(oLbx:Refresh(),oLbx:SetFocus()),oLbx:Hide()));
TOOLTIP(cDelTip)
return(oBar)

HTH

Colin

Example

Posted: Thu Dec 13, 2007 1:10 am
by TimStone
Thanks ... it makes sense now.

Of course that would add a lot of work for me ... but thats OK ... it makes it interesting.

I appreciate the guidance ... now I'll plug away at it !

Posted: Thu Dec 13, 2007 8:22 am
by James Bott
Tim,

It's not hard, you can still use the command line, just inside a function called by the ON INIT.

James

Code: Select all

   activate dialog oDlg on init buildBar(oDlg)
...
static function buildBar(oDlg)
   local oBar
   define buttonbar oBar of oDlg
   ...
return nil

Not Hard

Posted: Thu Dec 13, 2007 3:28 pm
by TimStone
James,

No, its not hard ... I've already got it implemented in one dialog that was very important for the change. However, whats hard is going back through so many dialogs and deciding which ones operate better with dialogs and then making the changes ...

I guess hard is not the best word ... time consuming is more appropriate, especially when I need to go Christmas shopping ....

However, its working out ...

Tim