Thanks Mike. I tried your code and it worked (that was enough to make my day!) Then I realized I wanted the Cancel to be the default. I went to the MSDN site, found the parameter & tried for a while to figure it out. Then I thought hints & colors would be a good idea and so I created a generic 3 button R:Base form, YesNoCancel, as Emmitt, Larry & Javier suggested so I could get it "just so". I predefine hints, captions and message and apply them in an AfterStart EEP; they can changed to suit the specific need.
Each button on the form sets the appropriate vYNCResponse value.

SET VAR +
 vYNCCancelHint TEXT = ('Return to editing.'), +
 vYNCCaption text = ('Finished Edtiting'), +
 vYNCMsg TEXT = ('Do you want to exit and update?'), +
 vYNCNoHint TEXT = ('Discard all changes and exit.'), +
 vYNCResponse TEXT = NULL, +
 vYNCYesHint TEXT = ('Process the data and exit.')

EDIT USING YesNoCancel
CLEAR VAR vYNCCancelHint,vYNCCaption,vYNCNoHint,vYNCYesHint,vYNCMsg

IF vYNCResponse = ('Cancel') THEN
 RETURN
ENDIF

IF vYNCResponse = ('No') THEN
 CLOSEWINDOW
 RETURN
ENDIF

IF vYNCResponse = ('Yes') THEN
 CLOSEWINDOW
 RETURN
[process in calling form]
ENDIF

Thanks to all
Doug

MikeB wrote:

Doug,

How about using the wonderful Windows MessageBox?  Here's how:
NOTE: You have to supply a HANDLE for the Message box. If you do not supply a handle, it will become modeless and can be buried behind the users view.. HANDLE is an undocumented value that is accessible with the GETPROPERTY CompID HANDLE 'vHandleText' command. You need to convert the text to INTEGER before passing it to the function.

The example shown here does NOT have an icon, but by changing the UINT value, you can include the standard Windows Icons for the Message box. You VB/VBA users will recognize the structure of the MessageBox as the underlying control used by those languages.

In your forms OnBefore:
{ The declaration arguments are:
1 is an UINT (use RBase Integer) for the type of message box,
2 is the Caption of the message box,
3 is the Message to be displayed,
4 is the handle of the owner window (the current form or control}
}

IF (chkfunc('MessageBoxA')) = 0 THEN
 STDCALL function 'MessageBoxA' alias 'MessageBox' +
 (integer, ptr text (128), ptr text, integer  ) : integer
ENDIF

In your controls EEP:
{Get the HANDLE of the owner window (form or control)}
SET VAR vthiswndtxt TEXT = NULL
GETPROPERTY RBASE_FORM HANDLE 'vThisWndtxt'
SET VAR vcallerhwnd = (INT(.vthiswndtxt))

SET VAR mb_yesnocancel = 3
SET VAR vretval INTEGER = 0
SET VAR vcaption TEXT = 'This is the Caption'

SET VAR vmsg TEXT = ('This is the Message first Line' + +
(CHAR(13)) +  (CHAR(10)) + +
'Select Yes, No, or Cancel')


--                                  Type     Caption   Message  OwnerWnd
-- function 'MessageBox' (integer, text (128), text, integer  ) : integer

SET VAR vretval = (dlcall('user32.dll', 'MessageBoxA', mb_yesnocancel, vcaption, vmsg, vcallerhwnd))

SWITCH (.vretval)
 CASE 6
   PAUSE 2 USING 'You Selected YES  '
   BREAK
 CASE 7
   PAUSE 2 USING 'You Selected  NO '
   BREAK
 CASE 2
   PAUSE 2 USING 'You Selected CANCEL  '
   BREAK
 DEFAULT
   PAUSE 2 USING 'You Selected CANCEL  '
   BREAK
ENDSW


RECALC VARIABLES


{ All of the constant values to make up the various incarnations of the MessageBox can be found at Microsoft's MSDN Library, this URL:
<:http://msdn.microsoft.com/en-us/library/ms645505(VS.85).aspx>


}



-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Doug
Hamilton
Sent: Monday, March 16, 2009 11:40 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - 3 Button Pause/Dialog?

Can Pause or Dialog boxes have three buttons?
Or should I build a quick mini-form w/ 3 buttons?

Situation:
User clicks exit button on a form after editing.
Pause/Dialog/whatever, pops up for confirmation:
___
Do you want to update the data?
 Yes     No     Cancel

Yes - updates & exits
No - Exits without updating
Cancel - returns to the form for more editing

I could have two separate buttons on the form (Yes & No, Cancel is
unneeded), but you know user will click "Yes" which will instantaneously
illicit a "D'OH!".  Confirmation-after-click is much preferred.

Or, ('cause it's Monday), what obvious solution am I not seeing?
TIA
Doug





Reply via email to