bb.donnay-software.com

Donnay Software Web Forums
It is currently Sat May 30, 2020 11:17 pm

All times are UTC - 7 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Do an action on CANCEL
PostPosted: Sat Mar 11, 2017 8:18 pm 
Offline
User avatar

Joined: Tue Jul 28, 2015 5:15 am
Posts: 94
How do you do an action when CANCEL was pressed.


Code:
STATIC FUNCTION XSample_3

/*
@ SAY..GETS (PIXEL BASED)

This sample demonstrates several @ DCSAY..GETs with automatic sizing
of the dialog window to the objects and an additional set of buttons
for OK and CANCEL.  The window is MODAL.  Coordinates are PIXEL-based.
*/

   LOCAL GetList := {}, dDate := Date(), nNumber := 12345.67, ;
         cString := 'This is a string', lLogical := .t., GetOptions

   SET DATE FORMAT TO 'mm/dd/yyyy'
   @ 10,1 DCSAY 'Enter a Date' GET dDate PICTURE '99/99/9999' ;
          SAYRIGHT GETSIZE 100
   @ 30,1 DCSAY 'Enter a Number' GET nNumber SAYRIGHT
   @ 50,1 DCSAY 'Enter a String' GET cString SAYRIGHT
   @ 70,1 DCSAY 'Enter Yes or No' GET lLogical PICTURE 'Y' SAYRIGHT

   DCGETOPTIONS ;
      WINDOWHEIGHT 300 ;
      WINDOWWIDTH 400  ;
      SAYWIDTH 120 ;
      PIXEL ;
      TITLE 'Data Entry' // Store options to GetOptions

   DCREAD GUI ;
      TITLE 'Pixel-Based GETs' ;
      BUTTONS DCGUI_BUTTON_OK + DCGUI_BUTTON_CANCEL ;
      MODAL ;
      OPTIONS GetOptions

// evaluate here if cancel was pressed
// if cancel is pressed, say "Hello Cancel is pressed" in a dialog.

RETURN nil
*** END OF EXAMPLE ***


Top
 Profile  
 
PostPosted: Sun Mar 12, 2017 8:15 am 
Offline
Site Admin
User avatar

Joined: Wed Jan 27, 2010 6:58 pm
Posts: 4125
Location: Boise, Idaho USA
Use the ABORTQUERY clause of DCGETOPTIONS
Code:
DCGETOPTIONS ;
  ABORTQUERY MSG {|x|(DCMSGBOX 'Do you really want to cancel?' YESNO TO x),x}

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


Top
 Profile  
 
PostPosted: Tue Mar 14, 2017 9:02 pm 
Offline
User avatar

Joined: Tue Jul 28, 2015 5:15 am
Posts: 94
Very good. Works for a message.

Is it possible to call a function when Cancel is pressed.


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 6:12 am 
Offline
Site Admin
User avatar

Joined: Wed Jan 27, 2010 6:58 pm
Posts: 4125
Location: Boise, Idaho USA
Quote:
Is it possible to call a function when Cancel is pressed.


ABORTQUERY was designed to give the programmer the ability to control the exit process of a window.
This is why it requires a code block. Anything can be put into a code block. In the sample I showed you there was only a DCMSGBOX because that's what you said you wanted. You can call any functions that return any values except the last function (expression) must return a logical value. If a .T. is returned then exit will occur, otherwise it will not.

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


Top
 Profile  
 
PostPosted: Thu Mar 16, 2017 5:08 am 
Offline
User avatar

Joined: Tue Jul 28, 2015 5:15 am
Posts: 94
Perfect.

Choo choo !


Top
 Profile  
 
PostPosted: Thu Mar 16, 2017 6:51 am 
Offline

Joined: Thu Jan 28, 2010 1:22 am
Posts: 863
Location: Sijsele, Belgium
Hi,

Don't forget that some users hit the ESCAPE key, or click on that nice 'X' in the upper right corner...

See in the dcgetiotions for ABORTQUERY, CLOSEQUERY, EXITQUERY, QUITQUERY

The NOESCAPEKEY clause can also help.

_________________
Best regards,

Chris.
www.aboservice.be


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group