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

Dialog Editor version 6.X
plus
plus

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

Dealing with Alt-F4 in Dialog


Question:

I need a way to know if a user has pressed Alt-F4 instead of Enter in a dialog. Alternatively I would happy if I could disable Alt-F4 completely. Any way to do either?

Answer:

Alt-F4 is basically "Close" which is basically CANCEL. If you have a standard dialog then use a :cancel handler. Or if you got the dynamic dialog code attached to it, then handle the CANCEL pushbutton.

#DefineFunction NoAltF4Proc(Noaltf4_Handle,Noaltf4_Message,Noaltf4_ID,rsvd1,rsvd2)
   Switch Noaltf4_Message                           ; Switch based on Dialog Message type
      Case 0                                        ; Standard Initialization message
         DialogProcOptions(Noaltf4_Handle,1002, 0)    ; Turn off system menus
       DialogProcOptions(Noaltf4_Handle,11, @TRUE)  ; Want close message.
       Return(-1)

     Case 11                                       ; Alt F4 pressed caught here.
       Return (-2)                                 ; Prevents exit from dialog.
   EndSwitch                                       ; Noaltf4_Message
   Return(-1)
#EndFunction                                       ; End of Dialog Callback Noaltf4CallbackProc

Noaltf4Format=`WWWDLGED,6.1`

Noaltf4Caption=`Alt F4 Dialog Example`
Noaltf4X=001
Noaltf4Y=001
Noaltf4Width=307
Noaltf4Height=203
Noaltf4NumControls=002
Noaltf4Procedure=`NoAltF4Proc`
Noaltf4Font=`DEFAULT`
Noaltf4TextColor=`DEFAULT`
Noaltf4Background=`DEFAULT,DEFAULT`
Noaltf4Config=0

Noaltf4001=`079,186,033,011,PUSHBUTTON,DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT`
Noaltf4002=`194,186,034,011,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("Noaltf4")

Article ID:   W16916
File Created: 2007:07:03:14:27:04
Last Updated: 2007:07:03:14:27:04