Here is another way to disable the Esc key.
Disabling the X (close) Button of a Dialog
In Workshop, double click on the dialog, and under the "Dialog Style" group, uncheck the "system menu" item.
Or, change nStyle by leaving off the WS_SYSMENU:
function main
local oDlg, nStyle :=nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION )
define dialog oDlg style nStyle
activate dialog oDlg
return nil
If you remove the (X) button then the Escape key doesn't work to close the dialog.
This is really a better solution. When the (X) button is on the dialog it is not obvious what happens when it is used. Is it like pressing OK button, or the Cancel button--the user is never quite sure. So, it is better to just remove it.
James