Page 1 of 1

Blocking buttons

Posted: Tue Oct 15, 2019 11:51 am
by omni
Roger,

We use addbuttons on most menu options, and on a lot of big jobs we give them progress of what the system is doing with osay on the same window.
The issue is that the user can stilll click on ok/cancel and stop the job, which actually causes an error.
Is there a built-in method to stop them from clicking anything once ok is clicked. On some I do not like to use waiton, or users to not like it. Actually does not happen very often but still want to block it.
Suppose I could add my own ok/cancel and then use a WHEN to not allow it, but did not know if you can do it with addbuttons.

Sample below:

@ 7,2 DCSAY "" SAYSIZE 50 SAYOBJECT oSAY1


DCGETOPTIONS NORESIZE TABSTOP COLOR &QQONE ;
SAYRIGHTBOTTOM ;
CHECKGET EXITVALIDATE ;
NOESCAPEKEY ;
TITLE 'EMAIL TRIAL STATEMENTS' ;

DCREAD GUI ADDBUTTONS ;
TO lStatus ;
ENTEREXIT FIT ;
; // MODAL ;
OPTIONS GetOptions ;
APPWINDOW oMainDialog:drawingArea ;
NODESTROY ;
PARENT @oDialog ;
; // SAVE



Thanks
fred
Omni

Re: Blocking buttons

Posted: Wed Oct 16, 2019 6:46 am
by Tom
Hi, Fred.

Look at the BUTTONS clause of DCGET OPTIONS. It accepts a two-dim array for the buttons to be added, like this:

Code: Select all

DCGET OPTIONS ;
BUTTONS {{"OK",30,20,{||lOk:=.T.,DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)} },;
         {"CANCEL",50,20,{||lOk:=.F.,DC_ReadGuiEvent(DCGUI_EXIT_ABORT,GetList)} } } ;
         ICON MY_ICON

DCREAD GUI ... BUTTONS DCGUI_BUTTONS_CUSTOM
Every line of this BUTTONS-array may be up to 12 or 13 items long (in the sample, every line has 4 items - 1 is the caption, 2 the width, 3 the height, 4 the action codeblock). Item # 8 is a WHEN clause for those buttons.