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
DCREAD GUI - ACTION OF THE OK BUTTON AND THE CANCEL BUTTON
Re: DCREAD GUI - ACTION OF THE OK BUTTON AND THE CANCEL BUTT
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
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.
Re: DCREAD GUI - ACTION OF THE OK BUTTON AND THE CANCEL BUTT
Thank you Roger.
For the readers of this Subject, there is a sample in xDemo
In Samples Set 2
In ArrayEdit number 49
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
and the function would look like this
Choo-Choo
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.
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) }
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.
-
- 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
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.