| 1 | {$INCLUDE switches}
|
|---|
| 2 | unit Inp;
|
|---|
| 3 |
|
|---|
| 4 | interface
|
|---|
| 5 |
|
|---|
| 6 | uses
|
|---|
| 7 | ScreenTools, Messg,
|
|---|
| 8 |
|
|---|
| 9 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
|
|---|
| 10 | ButtonA, StdCtrls, ButtonB, ButtonBase;
|
|---|
| 11 |
|
|---|
| 12 | type
|
|---|
| 13 | TInputDlg = class(TDrawDlg)
|
|---|
| 14 | OKBtn: TButtonA;
|
|---|
| 15 | EInput: TEdit;
|
|---|
| 16 | procedure OKBtnClick(Sender: TObject);
|
|---|
| 17 | procedure FormPaint(Sender: TObject);
|
|---|
| 18 | procedure FormCreate(Sender: TObject);
|
|---|
| 19 | procedure EInputKeyPress(Sender: TObject; var Key: Char);
|
|---|
| 20 | procedure FormShow(Sender: TObject);
|
|---|
| 21 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|---|
| 22 | public
|
|---|
| 23 | procedure CenterToRect(Rect: TRect);
|
|---|
| 24 | private
|
|---|
| 25 | Center: boolean;
|
|---|
| 26 | end;
|
|---|
| 27 |
|
|---|
| 28 | var
|
|---|
| 29 | InputDlg: TInputDlg;
|
|---|
| 30 |
|
|---|
| 31 | implementation
|
|---|
| 32 |
|
|---|
| 33 | {$R *.DFM}
|
|---|
| 34 |
|
|---|
| 35 | procedure TInputDlg.FormCreate(Sender: TObject);
|
|---|
| 36 | begin
|
|---|
| 37 | Canvas.Font.Assign(UniFont[ftNormal]);
|
|---|
| 38 | Canvas.Brush.Style := bsClear;
|
|---|
| 39 | TitleHeight := ClientHeight;
|
|---|
| 40 | InitButtons();
|
|---|
| 41 | Center := true
|
|---|
| 42 | end;
|
|---|
| 43 |
|
|---|
| 44 | procedure TInputDlg.FormPaint(Sender: TObject);
|
|---|
| 45 | begin
|
|---|
| 46 | PaintBackground(self, 3, 3, ClientWidth - 6, ClientHeight - 6);
|
|---|
| 47 | Frame(Canvas, 0, 0, ClientWidth - 1, ClientHeight - 1, 0, 0);
|
|---|
| 48 | Frame(Canvas, 1, 1, ClientWidth - 2, ClientHeight - 2,
|
|---|
| 49 | MainTexture.clBevelLight, MainTexture.clBevelShade);
|
|---|
| 50 | Frame(Canvas, 2, 2, ClientWidth - 3, ClientHeight - 3,
|
|---|
| 51 | MainTexture.clBevelLight, MainTexture.clBevelShade);
|
|---|
| 52 | EditFrame(Canvas, EInput.BoundsRect, MainTexture);
|
|---|
| 53 | BtnFrame(Canvas, OKBtn.BoundsRect, MainTexture);
|
|---|
| 54 | RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, Caption)) div 2,
|
|---|
| 55 | 9, Caption);
|
|---|
| 56 | { Corner(canvas,1,1,0,MainTexture);
|
|---|
| 57 | Corner(canvas,ClientWidth-9,1,1,MainTexture);
|
|---|
| 58 | Corner(canvas,1,ClientHeight-9,2,MainTexture);
|
|---|
| 59 | Corner(canvas,ClientWidth-9,ClientHeight-9,3,MainTexture); }
|
|---|
| 60 | end;
|
|---|
| 61 |
|
|---|
| 62 | procedure TInputDlg.OKBtnClick(Sender: TObject);
|
|---|
| 63 | begin
|
|---|
| 64 | if EInput.Text = '' then
|
|---|
| 65 | ModalResult := mrCancel
|
|---|
| 66 | else
|
|---|
| 67 | ModalResult := mrOK
|
|---|
| 68 | end;
|
|---|
| 69 |
|
|---|
| 70 | procedure TInputDlg.EInputKeyPress(Sender: TObject; var Key: Char);
|
|---|
| 71 | begin
|
|---|
| 72 | if (Key = #13) and (EInput.Text <> '') then
|
|---|
| 73 | begin
|
|---|
| 74 | Key := #0;
|
|---|
| 75 | ModalResult := mrOK
|
|---|
| 76 | end
|
|---|
| 77 | else if Key = #27 then
|
|---|
| 78 | begin
|
|---|
| 79 | Key := #0;
|
|---|
| 80 | ModalResult := mrCancel
|
|---|
| 81 | end
|
|---|
| 82 | end;
|
|---|
| 83 |
|
|---|
| 84 | procedure TInputDlg.FormShow(Sender: TObject);
|
|---|
| 85 | begin
|
|---|
| 86 | OKBtn.Caption := Phrases.Lookup('BTN_OK');
|
|---|
| 87 | EInput.Font.Color := MainTexture.clMark;
|
|---|
| 88 | EInput.SelStart := 0;
|
|---|
| 89 | EInput.SelLength := Length(EInput.Text);
|
|---|
| 90 | if Center then
|
|---|
| 91 | CenterToRect(Rect(0, 0, Screen.Width, Screen.Height));
|
|---|
| 92 | end;
|
|---|
| 93 |
|
|---|
| 94 | procedure TInputDlg.FormClose(Sender: TObject; var Action: TCloseAction);
|
|---|
| 95 | begin
|
|---|
| 96 | Center := true
|
|---|
| 97 | end;
|
|---|
| 98 |
|
|---|
| 99 | procedure TInputDlg.CenterToRect(Rect: TRect);
|
|---|
| 100 | begin
|
|---|
| 101 | Center := false;
|
|---|
| 102 | Left := Rect.Left + (Rect.Right - Rect.Left - Width) div 2;
|
|---|
| 103 | Top := Rect.Top + (Rect.Bottom - Rect.Top - Height) div 2;
|
|---|
| 104 | end;
|
|---|
| 105 |
|
|---|
| 106 | end.
|
|---|