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
| unit box;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TDonnees=string;
Tbox = class(TEdit)
private
{ Déclarations privées }
FDonnees:TDonnees;
FOnChangeCase:TNotifyEvent;
Procedure SetDonnees(Donnees: TDonnees);
protected
{ Déclarations protégées }
public
Constructor Create(AOwner:TComponent); override;
procedure UpCaseFirstChar;
procedure Onchange(Sender: TObject);
{ Déclarations publiques }
published
{ Déclarations publiées }
property Donnees:TDonnees read FDonnees write SetDonnees;
property OnChangeCase : TNotifyEvent read FOnChangeCase write
FOnChangeCase;
end;
procedure Register;
implementation
procedure tbox.UpCaseFirstChar;
var FirstChar: Char;
str:string;
i, j:integer;
begin
str:=Text;
j:= length(str);
if Str = EmptyStr then Exit;
FirstChar := UpCase(Str[1]);
//for i=0 to i=j do begin
//if str[i]='-' then Upcase(str[i+1]);
//i:=i+1;
//end;
Text := FirstChar + Copy(Str, 2, Length(Str) - 1);
if Assigned(FOnChangeCase) then FOnChangeCase(Self);
end;
procedure tBox.Onchange(Sender: TObject);
begin
upcasefirstchar;
END;
//if Donnees=-1 then Text:=AnsiLowerCase(Text);
//if Assigned(FOnChangeCase) then FOnChangeCase(Self);
//end;
Constructor tbox.Create(AOwner:TComponent);
begin
InHerited Create(AOwner);
Font.Color:=ClGreen;
Donnees:='S';
FOnChangeCase:=nil;
end;
procedure tbox.SetDonnees (Donnees: TDonnees);
begin
if (Donnees<>'N') or (Donnees<>'S') or (Donnees <>'M') then Donnees:='S';
FDonnees:=Donnees;
if (donnees='M') then UpCaseFirstChar;
end;
procedure Register;
begin
RegisterComponents('Standard', [tbox]);
end;
end. |
Partager