unit NewEdit;
interface
uses
Classes, StdCtrls, Controls;
type TAlign = (alleft, alright, alcenter);
type TSeperator = (sedot, secomma);
type TReservation = (reAll, reNumbersOnly, reLettersOnly);
type TAlErrorEvent =
procedure(Sender: TObject; val: TAlign)
of Object;
type TReErrorEvent =
procedure(Sender: TObject; val: TReservation)
of Object;
type TNewEdit =
class(TEdit)
private
FOnAlError: TAlErrorEvent;
FOnReError: TReErrorEvent;
FAlign: TAlign;
FReservation: TReservation;
procedure SetAlign(Align: TAlign);
procedure SetReservation(reReservation: TReservation);
published
property Alignment: TAlign
read FAlign
write SetAlign;
property Reservation: TReservation
read FReservation
write SetReservation;
property OnAlError: TAlErrorEvent
read FOnAlError
write FOnAlError;
property OnReError: TReErrorEvent
read FOnReError
write FOnReError;
public
procedure CreateParams(
var Params: TCreateParams);
override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('
Standard', [TNewEdit]);
end;
procedure TNewEdit.SetAlign(Align: TAlign);
begin
if Align <> FAlign
then
if Align
in [alleft, alright, alcenter]
then
FAlign := Align
else
if Assigned(FOnAlError)
then
OnAlError(self, Align);
end;
procedure TNewEdit.SetReservation(reReservation: TReservation);
begin
if reReservation <> FReservation
then
if (reReservation
in [reAll, reNumbersOnly, reLettersOnly])
then
FReservation := reReservation
else
if Assigned(FOnReError)
then
OnReError(self, reReservation);
end;
procedure TNewEdit.CreateParams(
var Params: TCreateParams);
begin
inherited CreateParams(Params);
if FAlign = alright
then
Params.Style := Params.Style
or 2;
if FAlign = alleft
then
Params.Style := Params.Style
or 0;
if FAlign = alcenter
then
Params.Style := Params.Style
or 1;
end;
end.