I insert OnEvent>KEY_DOWN,VK_ESCAPE,0,DoCloseDialog before Show>Dialog1,ModalResult.
SRT>DoCloseDialog
CloseDialog>Dialog1
End>DoCloseDialog
During the display of Dialog1, pressing ESC won't close Dialog1.
OnEvent>KeyDown Fails
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
No, because you're showing the dialog modally. The OnEvent won't do anything while the dialog is closed.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Set the Cancel property of your Cancel button to true. This means that pressing Escape will invoke it. Try this:
Run the macro and then hit escape and you will see the dialog close.
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Left = 435
Top = 236
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 223
ClientWidth = 439
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSButton1: tMSButton
Left = 84
Top = 56
Width = 75
Height = 25
Cancel = True
ModalResult = 2
Caption = 'MSButton1'
DoubleBuffered = True
ParentDoubleBuffered = False
TabOrder = 8
DoBrowse = False
BrowseStyle = fbOpen
end
end
EndDialog>Dialog1
Show>Dialog1,r
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?