-
Notifications
You must be signed in to change notification settings - Fork 86
/
uFrmLineNumber.pas
49 lines (40 loc) · 1.03 KB
/
uFrmLineNumber.pas
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
unit uFrmLineNumber;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Vcl.Samples.Spin;
type
TfrmGoToLineNumber = class(TForm)
spnLine: TSpinEdit;
btnOk: TButton;
btnCancel: TButton;
Label1: TLabel;
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmGoToLineNumber: TfrmGoToLineNumber;
implementation
{$R *.dfm}
procedure TfrmGoToLineNumber.FormKeyPress(Sender: TObject; var Key: Char);
begin
if spnLine.Focused and (Key = #13) then
begin
Key := #0; // Cancels the keypress
Perform(CM_DIALOGKEY, VK_RETURN, 0); // Invokes the default button
end;
if spnLine.Focused and (Key = #$1B) then
begin
Key := #0; // Cancels the keypress
Perform(CM_DIALOGKEY, VK_ESCAPE, 0); // Invokes the cancel button
end;
end;
procedure TfrmGoToLineNumber.FormShow(Sender: TObject);
begin
spnLine.SelectAll;
end;
end.