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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
| { ****************************************************************** }
{ }
{ VCL component TSaisie }
{ }
{ Code generated by Component Create for Delphi }
{ }
{ Generated from source file c:\users\les h\documents\delphi\saisie2.cd }
{ on 11 Feb 2011 at 22:05 }
{ }
{ Copyright © 2011 by H. Deconchat }
{ }
{ ****************************************************************** }
unit Saisie;
interface
uses WinTypes, WinProcs, Messages, SysUtils, Classes, Controls,
Forms, Graphics, Stdctrls, Extctrls;
type
TSaisie = class(TEdit)
private
{ Private fields of TSaisie }
{ Storage for property Affichage_couleur }
FAffichage_couleur : TColor;
{ Storage for property Code_Retour_a_la_ligne }
FCode_Retour_a_la_ligne : byte;
{ Storage for property Code_espace }
FCode_espace : byte;
{ Storage for property Code_tabulation }
FCode_tabulation : byte;
{ Storage for property Vitesse }
FVitesse : Integer;
{ Private methods of TSaisie }
{ Method to set variable and property values and create objects }
procedure AutoInitialize;
{ Method to free any objects created by AutoInitialize }
procedure AutoDestroy;
{ Read method for property Affichage_couleur }
function GetAffichage_couleur : TColor;
{ Write method for property Affichage_couleur }
procedure SetAffichage_couleur(Value : TColor);
{ Read method for property Code_Retour_a_la_ligne }
function GetCode_Retour_a_la_ligne : byte;
{ Write method for property Code_Retour_a_la_ligne }
procedure SetCode_Retour_a_la_ligne(Value : byte);
{ Read method for property Code_espace }
function GetCode_espace : byte;
{ Write method for property Code_espace }
procedure SetCode_espace(Value : byte);
{ Read method for property Code_tabulation }
function GetCode_tabulation : byte;
{ Write method for property Code_tabulation }
procedure SetCode_tabulation(Value : byte);
{ Read method for property Vitesse }
function GetVitesse : Integer;
{ Write method for property Vitesse }
procedure SetVitesse(Value : Integer);
protected
{ Protected fields of TSaisie }
Affichage : TLabel;
Changement : Boolean;
Temp : TTimer;
{ Protected methods of TSaisie }
procedure Change; override;
procedure Click; override;
procedure DoExit; override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure KeyPress(var Key : Char); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure Loaded; override;
public
{ Public fields and properties of TSaisie }
{ Public methods of TSaisie }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure fin(sender : TObject);
procedure sourie(Sender: TObject; Shift: TShiftState; X, Y: Integer);
published
{ Published properties of TSaisie }
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property Affichage_couleur : TColor
read GetAffichage_couleur write SetAffichage_couleur
default clYellow;
property Code_Retour_a_la_ligne : byte
read GetCode_Retour_a_la_ligne write SetCode_Retour_a_la_ligne
default 182;
property Code_espace : byte
read GetCode_espace write SetCode_espace
default 7;
property Code_tabulation : byte
read GetCode_tabulation write SetCode_tabulation
default 26;
property Vitesse : Integer
read GetVitesse write SetVitesse
default 500;
end;
procedure Register;
implementation
procedure Register;
begin
{ Register TSaisie with Herve as its
default page on the Delphi component palette }
RegisterComponents('Herve', [TSaisie]);
end;
{ Method to set variable and property values and create objects }
procedure TSaisie.AutoInitialize;
begin
Affichage := TLabel.Create(Self);
Affichage.Parent := Self;
with Affichage do
begin
autosize:=false;
Left := 1;
Top := 1;
Width := self.width;
Height := self.height;
font:=self.font;
color:=fAffichage_couleur;
Visible := false;
onmousemove:=sourie;
end;
Changement := True;
Temp := TTimer.Create(Self);
with Temp do
begin
interval:=1000;
enabled:=false;
ontimer:=fin;
end;
FAffichage_couleur := clYellow;
FCode_Retour_a_la_ligne := 182;
FCode_espace := 7;
FCode_tabulation := 26;
FVitesse := 500;
end; { of AutoInitialize }
{ Method to free any objects created by AutoInitialize }
procedure TSaisie.AutoDestroy;
begin
Affichage.Free;
Temp.Free;
end; { of AutoDestroy }
{ Read method for property Affichage_couleur }
function TSaisie.GetAffichage_couleur : TColor;
begin
Result := FAffichage_couleur;
end;
{ Write method for property Affichage_couleur }
procedure TSaisie.SetAffichage_couleur(Value : TColor);
begin
FAffichage_couleur := Value;
affichage.color:=FAffichage_couleur;
end;
{ Read method for property Code_Retour_a_la_ligne }
function TSaisie.GetCode_Retour_a_la_ligne : byte;
begin
Result := FCode_Retour_a_la_ligne;
end;
{ Write method for property Code_Retour_a_la_ligne }
procedure TSaisie.SetCode_Retour_a_la_ligne(Value : byte);
begin
FCode_Retour_a_la_ligne := Value;
change;
end;
{ Read method for property Code_espace }
function TSaisie.GetCode_espace : byte;
begin
Result := FCode_espace;
end;
{ Write method for property Code_espace }
procedure TSaisie.SetCode_espace(Value : byte);
begin
FCode_espace := Value;
change;
end;
{ Read method for property Code_tabulation }
function TSaisie.GetCode_tabulation : byte;
begin
Result := FCode_tabulation;
end;
{ Write method for property Code_tabulation }
procedure TSaisie.SetCode_tabulation(Value : byte);
begin
FCode_tabulation := Value;
change;
end;
{ Read method for property Vitesse }
function TSaisie.GetVitesse : Integer;
begin
Result := FVitesse;
end;
{ Write method for property Vitesse }
procedure TSaisie.SetVitesse(Value : Integer);
begin
FVitesse := Value;
temp.interval:=FVitesse;
end;
{ Override OnChange handler from TEdit }
procedure TSaisie.Change;
var n : integer;
tx : string;
begin
affichage.visible:=false;
inherited Change;
tx:='';
if length(text)>0 then
begin
for n:=1 to length(text) do
begin
case Ord(text[n]) of
9 : tx[n] := chr(fcode_tabulation);
32 : tx[n] := chr(fcode_espace);
13 : tx[n] := chr(fcode_Retour_a_la_ligne);
//10 : tx[n] := chr(fcode_saut_ligne);
end;
end;
affichage.caption:=tx;
end;
affichage.color:=FAffichage_couleur;
end;
{ Override OnClick handler from TEdit }
procedure TSaisie.Click;
begin
{ Code to execute before activating click
behavior of component's parent class }
{ Activate click behavior of parent }
inherited Click;
{ Code to execute after click behavior
of parent }
end;
{ Override OnExit handler from TEdit }
procedure TSaisie.DoExit;
begin
inherited DoExit;
temp.enabled:=false;
affichage.visible:=true;
end;
{ Override OnKeyDown handler from TEdit }
procedure TSaisie.KeyDown(var Key: Word; Shift: TShiftState);
begin
{ Key contains the Windows VK_ (virtual key) code of the key
that was pressed, such as VK_DELETE. Many are included in
the case statement below. For a complete list of VK_ codes,
search for Delphi help topic "Virtual Key Codes."
Shift is a set containing the state of the Shift, Ctrl, and Alt
keys. [ssShift] means only Shift key was down, [ssCtrl] means
only Ctrl key was down, [ssAlt] means only Alt key was down,
[ssShift, ssCtrl] means Ctrl+Shift, etc. }
case Key of
VK_BACK, VK_DELETE : { Backspace, DEL keys }
begin
{ Response to backspace/delete, if different
from or additional to response of parent class }
end;
VK_PRIOR, { PAGE UP key }
VK_NEXT, { PAGE DOWN key }
VK_END, { END key }
VK_HOME : { HOME key }
begin
end;
VK_LEFT, { LEFT ARROW key }
VK_UP, { UP ARROW key }
VK_RIGHT, { RIGHT ARROW key }
VK_DOWN : { DOWN ARROW key }
begin
end;
VK_TAB : { TAB key }
begin
end;
VK_INSERT : { INS key }
begin
end;
VK_ESCAPE : { ESC key }
begin
end;
end; { case }
{ Obtain the default response of the parent class to this keydown event }
inherited KeyDown(Key, Shift);
affichage.visible:=false;
temp.enabled:=true;
end;
{ Override OnKeyPress handler from TEdit }
procedure TSaisie.KeyPress(var Key : Char);
const
TabKey = Char(VK_TAB);
EnterKey = Char(VK_RETURN);
begin
{ Key contains the character produced by the keypress.
It can be tested or assigned a new value before the
call to the inherited KeyPress method. Setting Key
to #0 before call to the inherited KeyPress method
terminates any further processing of the character. }
{ Activate KeyPress behavior of parent }
inherited KeyPress(Key);
{ Code to execute after KeyPress behavior of parent }
end;
{ Override OnMouseMove handler from TEdit }
procedure TSaisie.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
temp.enabled:=false;
inherited MouseMove(Shift, X, Y);
affichage.visible:=false;
temp.enabled:=true;
end;
constructor TSaisie.Create(AOwner: TComponent);
begin
{ Call the Create method of the parent class }
inherited Create(AOwner);
{ AutoInitialize sets the initial values of variables and }
{ properties; also, it creates objects for properties of }
{ standard Delphi object types (e.g., TFont, TTimer, }
{ TPicture) and for any variables marked as objects. }
{ AutoInitialize method is generated by Component Create. }
AutoInitialize;
{ Code to perform other tasks when the component is created }
end;
destructor TSaisie.Destroy;
begin
{ AutoDestroy, which is generated by Component Create, frees any }
{ objects created by AutoInitialize. }
AutoDestroy;
{ Here, free any other dynamic objects that the component methods }
{ created but have not yet freed. Also perform any other clean-up }
{ operations needed before the component is destroyed. }
{ Last, free the component by calling the Destroy method of the }
{ parent class. }
inherited Destroy;
end;
procedure TSaisie.Loaded;
begin
inherited Loaded;
{ Perform any component setup that depends on the property
values having been set }
end;
procedure TSaisie.fin(sender : TObject);
begin
if activecontrol<>self then
begin
affichage.visible:=true;
temp.enabled:=false;
end;
end;
procedure TSaisie.sourie(Sender: TObject; Shift: TShiftState; X, Y: Integer);
{ Internal declarations for method }
{ type }
{ . . . }
{ var }
{ . . . }
begin
affichage.visible:=false;
temp.enabled:=true;
end;
end. |
Partager