How to display a dialog without default set button? (2)
;==========================================================================================================================================
;
; How to display a dialog without default set button? (2)
;
;------------------------------------------------------------------------------------------------------------------------------------------
; Modified sample script from WinBatch Tech Data Base.
; "Button Dialog With No Default Focus", Article ID W16404, 2005:02:18:11:20:25.
;
; (c)Detlev Dalitz.20120129.
;==========================================================================================================================================

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineSubRoutine InitDialogConstants ()
; DialogprocOptions Constants.
MSG_INIT = 0         ; The one-time initialization.
MSG_TIMER = 1        ; Timer event.
MSG_BUTTONPUSHED = 2 ; Pushbutton or Picturebutton.
; DialogControlState Constants.
DCSTATE_SETFOCUS = 1 ; Give Control Focus
DCSTATE_GETFOCUS = 5 ; Get control that has focus
; Return code constants.
RET_DO_CANCEL = 0    ; Cancels dialog.
RET_DO_DEFAULT = -1  ; Continue with default processing for control.
RET_DO_NOT_EXIT = -2 ; Do not exit the dialog.
Return
#EndSubRoutine
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineSubRoutine NoEnterCallbackProc (NoEnter_Handle, NoEnter_Message, NoEnter_Name, NoEnter_EventInfo, NoEnter_ChangeInfo)
Switch NoEnter_Message
Case MSG_INIT
   DialogProcOptions (NoEnter_Handle, MSG_TIMER, 100)
   DialogProcOptions (NoEnter_Handle, MSG_BUTTONPUSHED, @TRUE)
   Return RET_DO_DEFAULT

Case MSG_BUTTONPUSHED
   Switch @TRUE
   Case NoEnter_Name == "PushButton_OK"
      ; From mouse?
      ; Note: this takes care of all cases except when return key is pressed while mouse cursor is over OK buttton.
      If MouseInfo (0) == "OK"
         Return RET_DO_DEFAULT
      Else
         ; May cut down on processing by timer case?
         DialogControlState (NoEnter_Handle, "PushButton_OK", DCSTATE_SETFOCUS, 0)
         Return RET_DO_NOT_EXIT
      EndIf
   Case NoEnter_Name == "PushButton_Dummy"
      ; Gets return key pressed messages and does nothing.
      Return RET_DO_NOT_EXIT
   EndSwitch

Case MSG_TIMER
   ; Prevent the OK buttom from getting the input focus and, therefore, the return key press message.
   If DialogControlState (NoEnter_Handle, 0, DCSTATE_GETFOCUS, 0) == 001
      ; Change the focus to "Dummy" unless OK has the focus because of a mouse button down.
      If (MouseInfo (4) != 4) || (MouseInfo (0) != "OK")
         DialogControlState (NoEnter_Handle, "PushButton_OK", DCSTATE_SETFOCUS, 0)
      EndIf
   EndIf
   Return RET_DO_NOT_EXIT

EndSwitch
Return RET_DO_DEFAULT
#EndSubRoutine
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.
DirChange (DirScript ())

InitDialogConstants ()

NoEnterFormat = `WWWDLGED,6.2`
NoEnterCaption = `Pressing [Enter] or [Space+Tab] does not work, but mouse click will.`
NoEnterX = 100
NoEnterY = 100
NoEnterWidth = 200
NoEnterHeight = 100
NoEnterNumControls = 002
NoEnterProcedure = `NoEnterCallbackProc`
NoEnterFont = `DEFAULT`
NoEnterTextColor = `DEFAULT`
NoEnterBackground = `DEFAULT,DEFAULT`
NoEnterConfig = 0
NoEnter001 = `000,000,000,000,PUSHBUTTON,"PushButton_Dummy",DEFAULT,"",0,1,160,DEFAULT,DEFAULT,DEFAULT`
NoEnter002 = `050,040,100,020,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,2,0,DEFAULT,DEFAULT,DEFAULT`
ButtonPushed = Dialog ("NoEnter")
Exit
;------------------------------------------------------------------------------------------------------------------------------------------