-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathComUnit.pas
62 lines (51 loc) · 1.52 KB
/
ComUnit.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
50
51
52
53
54
55
56
57
58
59
60
61
62
unit ComUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls;
type
TComForm = class(TForm)
Bevel1: TBevel;
Label1: TLabel;
ComLabel: TLabel;
PortUpDown: TUpDown;
OKButton: TButton;
procedure FormActivate(Sender: TObject);
procedure PortUpDownClick(Sender: TObject; Button: TUDBtnType);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ComForm: TComForm;
implementation
uses GlobalUnit, SerialUnit;
{$R *.dfm}
procedure TComForm.FormActivate(Sender: TObject);
begin
PortUpDown.Position := CommPort;
ComLabel.Caption := CommString;
end;
procedure TComForm.PortUpDownClick(Sender: TObject; Button: TUDBtnType);
begin
CommPort := PortUpDown.Position;
ComLabel.Caption := CommString;
end;
procedure TComForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
case Key of
kUp, kSpace:
if PortUpDown.Position = PortUpDown.Max then PortUpDown.Position := PortUpDown.Min
else PortUpDown.Position := PortUpDown.Position + 1;
kDown:
if PortUpDown.Position = PortUpDown.Min then PortUpDown.Position := PortUpDown.Max
else PortUpDown.Position := PortUpDown.Position - 1;
kEnter:
ModalResult := mrOK;
end;
CommPort := PortUpDown.Position;
ComLabel.Caption := CommString;
end;
end.