WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

AskYesNo with Default NO

 Keywords: AskYesNo Default NO YES Focus Button

Question:

I am using the AskYesNo dialog and in normal use the "Yes" button is the default button, is it possible to change the default button to "No" ?

Answer:

Unfortunately the AskYesNo function does support changing the default button. This is because the underlying MessageBox API that is called doesn't support this. I recommend using the WIl Dialog Editor to create your own customized AskYesNo dialog.

For example:

#DefineFunction udfAskYesNo( title, text )
   MyDialogFormat=`WWWDLGED,6.2`
   MyDialogCaption=title
   MyDialogX=-1
   MyDialogY=-1
   MyDialogWidth=212
   MyDialogHeight=087
   MyDialogNumControls=004
   MyDialogProcedure=`DEFAULT`
   MyDialogFont=`DEFAULT`
   MyDialogTextColor=`DEFAULT`
   MyDialogBackground=`DEFAULT,DEFAULT`
   MyDialogConfig=0
   MyDialog001=`025,059,036,012,PUSHBUTTON,"PushButton_Yes",DEFAULT,"Yes",1,2,32,DEFAULT,DEFAULT,DEFAULT`
   MyDialog002=`129,059,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
   MyDialog003=`075,059,036,012,PUSHBUTTON,"PushButton_No",DEFAULT,"No",9999,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
   MyDialog004=`027,027,154,012,VARYTEXT,"VaryText_1",Text,"Text",DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
   ButtonPushed=Dialog("MyDialog")
   ; Special handling of 0 value, because zero has special meaning to Dialogs
   If ButtonPushed == 9999 Then ButtonPushed = 0
   Return ButtonPushed
#EndFunction

ret = udfAskYesno( 'title', 'Your question goes here.' )

If ret == @YES
    Pause( 'User Selected', 'YES' )
Else
    Pause( 'User Selected', 'NO' )
EndIf

Exit

Article ID:   W17890
Filename:   AskYesNo with Default NO.txt
File Created: 2009:03:05:09:57:52
Last Updated: 2009:03:05:09:57:52