FIX: Crash if close message dialog by 'X' window button

This commit is contained in:
Alexander Koblov 2017-02-02 17:57:35 +00:00
commit 0df55731cb
2 changed files with 11 additions and 4 deletions

View file

@ -12,14 +12,15 @@ object frmMsg: TfrmMsg
ClientWidth = 426
Constraints.MinWidth = 250
KeyPreview = True
OnClose = FormClose
OnCreate = FormCreate
OnKeyDown = FormKeyDown
OnKeyPress = FormKeyPress
LCLVersion = '1.6.0.3'
LCLVersion = '1.6.0.4'
object lblMsg: TLabel
AnchorSideRight.Side = asrBottom
Left = 12
Height = 15
Height = 18
Top = 12
Width = 402
Align = alTop
@ -33,8 +34,8 @@ object frmMsg: TfrmMsg
object pnlButtons: TPanel
AnchorSideBottom.Side = asrBottom
Left = 12
Height = 203
Top = 39
Height = 200
Top = 42
Width = 402
Align = alClient
AutoSize = True

View file

@ -13,6 +13,7 @@ type
lblMsg: TLabel;
pnlButtons: TPanel;
mnuOther: TPopupMenu;
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormKeyPress(Sender: TObject; var Key: Char);
@ -41,6 +42,11 @@ begin
iSelected:= -1;
end;
procedure TfrmMsg.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
if (iSelected < 0) and (Escape >= 0) then iSelected:= Escape;
end;
procedure TfrmMsg.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
Index: Integer;