DCREAD GUI - ACTION OF THE OK BUTTON AND THE CANCEL BUTTON

If you are converting a text-based Clipper application, a FoxPro application or just writing an application from scratch, use this forum for your eXpress++ questions.
Post Reply
Message
Author
User avatar
alepap
Posts: 94
Joined: Tue Jul 28, 2015 5:15 am

DCREAD GUI - ACTION OF THE OK BUTTON AND THE CANCEL BUTTON

#1 Post by alepap »

With Express, when using
DCREAD GUI ;
ADDBUTTONS

You get a Ok Button and a Cancel Button.

1) What are the ACTION of these Buttons?

2) How can I find out what is the ACTION of a button, where is it located?

Thank you,

Alexandre

User avatar
rdonnay
Site Admin
Posts: 4340
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCREAD GUI - ACTION OF THE OK BUTTON AND THE CANCEL BUTT

#2 Post by rdonnay »

If you look at line 3425 of _DCGETBX.PRG, this is where those buttons are created.

They are added to the GetList.

The ACTION for the OK button is {||DC_ReadGuiExit(self)}
The ACTION for the CANCEL button is {||DC_ReadGuiAbort(self)}

This is functionally equivalent to:

{||DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}

and

{||DC_ReadGuiEvent(DCGUI_EXIT_ABORT,GetList)}


If you wish to change the ACTION clause you can override it by adding your own buttons with the BUTTONS clause.

Another trick, is to search for the buttons and change the action clause.

DCREAD GUI EVAL {||ChangeOKButtonAction(GetList)}

* -----------

FUNCTION ChangeOKButtonAction(GetList)

oButton := DC_GetObject(GetList,'DCGUI_BUTTON_OK')
oButton:activate := {||MsgBox('You are OK to leave this window'),DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}

RETURN nil
The eXpress train is coming - and it has more cars.

User avatar
alepap
Posts: 94
Joined: Tue Jul 28, 2015 5:15 am

Re: DCREAD GUI - ACTION OF THE OK BUTTON AND THE CANCEL BUTT

#3 Post by alepap »

Thank you Roger.

For the readers of this Subject, there is a sample in xDemo
In Samples Set 2
In ArrayEdit number 49

Code: Select all

ELSEIF nAction = 9 // Exit and Save

  IF DC_MsgBox(,,{'Exit and Save Changes?'},,,,.t.)
    DC_ReadGuiEvent(DCGUI_EXIT_OK,aGetList)
  ENDIF
  RETURN .t.

ELSEIF nAction = 10 // Exit and Abort

  IF DC_MsgBox(,,{'Exit and Abort Changes?'},,,,.t.)
    DC_ReadGuiEvent(DCGUI_EXIT_ABORT,aGetList)
  ENDIF
  RETURN .t.

This is helpful when you whant to terminate the DCREAD GUI by another BUTTON.

Than you would have something like this in BUTTON before the DCREAD GUI

Code: Select all

   @ 27,135 DCPUSHBUTTON CAPTION 'PGDN' SIZE 9,1.2 ;
         ID 'PAGE_DN' ;
         ACTION {|| sSCRGUI_PGDN(GetList) }
and the function would look like this

Code: Select all

FUNCTION sSCRGUI_PGDN(aGetlist)

   DC_ReadGuiEvent(DCGUI_EXIT_OK,aGetList)  // this terminates the DCREAD
   zEPGDN() // this is just another function that I execute...

RETURN .T.
Choo-Choo

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: DCREAD GUI - ACTION OF THE OK BUTTON AND THE CANCEL BUTT

#4 Post by Cliff Wiernik »

I use the add buttons when I simply what an OK or cancel. However, if you want to validate something upon clicking OK, I usually add my own buttons in order to give the desired level of control I need prior to the dialog exiting and clearing. If I control the action, I am still in the dialog and can act according.

Post Reply