Menu

[r3207]: / trunk / Src / FmGenericNonModalDlg.pas  Maximize  Restore  History

Download this file

88 lines (67 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/
*
* Copyright (C) 2013, Peter Johnson (www.delphidabbler.com).
*
* $Rev$
* $Date$
*
* Implements a base class for all the program's non-modal dialogue boxes.
}
unit FmGenericNonModalDlg;
interface
uses
// Delphi
StdCtrls, Controls, ExtCtrls, Classes,
// Project
FmGenericDlg;
type
/// <summary>Base class for all non-modal dialogue boxes in the program.
/// </summary>
/// <remarks>By default non-modal dialogue boxes are fixed size tool windows.
/// </remarks>
TGenericNonModalDlg = class(TGenericDlg)
btnClose: TButton;
/// <summary>Traps key down events on form. Closes dialogue box if
/// unshifted ESC key detected.</summary>
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
/// <summary>Handles clicks on Close button by closing form.</summary>
procedure btnCloseClick(Sender: TObject);
strict protected
/// <summary>Positions controls and sizes dialogue box form.</summary>
/// <remarks>This override positions Close button in addition to inherited
/// behaviour.</remarks>
procedure ArrangeForm; override;
end;
implementation
uses
// Delphi
Windows,
// Project
UCtrlArranger;
{$R *.dfm}
{ TGenericNonModalDlg }
procedure TGenericNonModalDlg.ArrangeForm;
begin
inherited;
// Arrange Close to left of any Help button
TCtrlArranger.AlignTops([btnHelp, btnClose]);
if btnHelp.Visible then
TCtrlArranger.MoveToLeftOf(btnHelp, btnClose, 4)
else
btnClose.Left := btnHelp.Left;
end;
procedure TGenericNonModalDlg.btnCloseClick(Sender: TObject);
begin
Close;
end;
procedure TGenericNonModalDlg.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if (Key = VK_ESCAPE) and (Shift = []) then
Close;
end;
end.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.