unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TEdit =
class(StdCtrls.TEdit)
private
FAlignment: Classes.TAlignment;
procedure SetAlignment(
const Value: TAlignment);
protected
procedure CreateParams(
var Params: TCreateParams);
override;
public
property Alignment: TAlignment
read FAlignment
write SetAlignment
default taLeftJustify;
end;
TForm1 =
class(TForm)
edt1: TEdit;
edt2: TEdit;
edt3: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TEdit }
procedure TEdit.CreateParams(
var Params: TCreateParams);
begin
inherited;
case FAlignment
of
taLeftJustify: Params.Style := Params.Style
and not (ES_RIGHT
or ES_CENTER)
or ES_LEFT;
taRightJustify: Params.Style := Params.Style
and not (ES_LEFT
or ES_CENTER)
or ES_RIGHT;
taCenter: Params.Style := Params.Style
and not (ES_RIGHT
or ES_LEFT)
or ES_CENTER;
end;
end;
procedure TEdit.SetAlignment(
const Value: TAlignment);
begin
if FAlignment <> Value
then
begin
FAlignment := Value;
RecreateWnd;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
edt1.Alignment := taLeftJustify;
edt2.Alignment := taRightJustify;
edt3.Alignment := taCenter;
end;
end.