This repository was archived by the owner on Mar 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathEditorString.pas
More file actions
151 lines (128 loc) · 4.27 KB
/
Copy pathEditorString.pas
File metadata and controls
151 lines (128 loc) · 4.27 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
unit EditorString;
//----------------------------------------------------------------------------------------------------------------------
//
// This file is part of fabFORCE DBDesigner4.
// Copyright (C) 2002 Michael G. Zinner, www.fabFORCE.net
//
// DBDesigner4 is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// DBDesigner4 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with DBDesigner4; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//----------------------------------------------------------------------------------------------------------------------
//
// Unit EditorString.pas
// ---------------------
// Version 1.0, 13.03.2003, Mike
// Description
// Asks the user to type in or modify a string
//
// Changes:
// Version 1.0, 13.03.2003, Mike
// initial version
//
//----------------------------------------------------------------------------------------------------------------------
interface
uses
SysUtils, Types, Classes, LResources, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls;
type
TEditorStringForm = class(TForm)
PromtLbl: TLabel;
InputPnl: TPanel;
ValueEd: TEdit;
OKBtn: TSpeedButton;
CancelBtn: TSpeedButton;
procedure OKBtnClick(Sender: TObject);
procedure CancelBtnClick(Sender: TObject);
procedure SetParams(ATitle, APromt, Value: string; SelectionStart: integer = 0; LimitChars: integer = 0);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ValueEdChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
LimitCharsMode: integer;
public
{ Public-Deklarationen }
end;
var
EditorStringForm: TEditorStringForm;
implementation
uses MainDM;
// {$R *.xfm}
{$mode delphi}{$H+}
procedure TEditorStringForm.FormCreate(Sender: TObject);
begin
DMMain.InitForm(self);
end;
procedure TEditorStringForm.OKBtnClick(Sender: TObject);
begin
ModalResult:=mrOK;
end;
procedure TEditorStringForm.CancelBtnClick(Sender: TObject);
begin
ModalResult:=mrCancel;
end;
procedure TEditorStringForm.SetParams(ATitle, APromt, Value: string; SelectionStart: integer = 0; LimitChars: integer = 0);
begin
Caption:=ATitle;
PromtLbl.Caption:=APromt;
ValueEd.Text:=Value;
ValueEd.SelStart:=SelectionStart;
ValueEd.SelLength:=Length(value)-SelectionStart;
LimitCharsMode:=LimitChars;
InputPnl.Left:=PromtLbl.Left+PromtLbl.Width+2;
Width:=InputPnl.Left+InputPnl.Width+PromtLbl.Left;
end;
procedure TEditorStringForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if(Key=Key_Return)then
OKBtnClick(self);
end;
procedure TEditorStringForm.ValueEdChange(Sender: TObject);
var i: integer;
begin
if(LimitCharsMode=0)then
Exit;
i:=1;
while(i<=Length(ValueEd.Text))do
begin
if(LimitCharsMode=1)then
begin
if(Not(
((ValueEd.Text[i]>='A')and(ValueEd.Text[i]<='Z'))or
((ValueEd.Text[i]>='a')and(ValueEd.Text[i]<='z'))or
((ValueEd.Text[i]>='0')and(ValueEd.Text[i]<='9'))or
(ValueEd.Text[i]=' ')or(ValueEd.Text[i]='_')or
(ValueEd.Text[i]='.')
))then
ValueEd.Text:=Copy(ValueEd.Text, 1, i-1)+
Copy(ValueEd.Text, i+1, Length(ValueEd.Text));
end;
if(LimitCharsMode=2)then
begin
if(Not(
((ValueEd.Text[i]>='A')and(ValueEd.Text[i]<='Z'))or
((ValueEd.Text[i]>='a')and(ValueEd.Text[i]<='z'))or
((ValueEd.Text[i]>='0')and(ValueEd.Text[i]<='9'))
))then
ValueEd.Text:=Copy(ValueEd.Text, 1, i-1)+
Copy(ValueEd.Text, i+1, Length(ValueEd.Text));
end;
inc(i);
end;
end;
end.
initialization
{$I EditorString.lrs}
end.