给你源代码,刚写的,可以用。
unit AEdit;
interface
uses
Windows,
SysUtils,
Messages,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
Menus,
StdCtrls,
ExtCtrls;
type
TEoCEdit = class(TEdit)
private
{ Private declarations }
FAlignment: TAlignment;
protected
{ Protected declarations }
function GetAlignment: TAlignment; virtual;
procedure SetAlignment(newValue: TAlignment); virtual;
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published properties and events }
property Alignment: TAlignment read GetAlignment write SetAlignment; { Published }
end; { TEoCEdit }
procedure Register;
implementation
function TEoCEdit.GetAlignment: TAlignment;
{ Returns the value of data member FAlignment. }
begin
GetAlignment := FAlignment;
end; { GetAlignment }
procedure TEoCEdit.SetAlignment(newValue: TAlignment);
{ Sets data member FAlignment to newValue. }
begin
if FAlignment <> newValue then
begin
FAlignment := newValue;
if not (csLoading in componentstate) then ReCreateWnd;
end;
end; { SetAlignment }
destructor TEoCEdit.Destroy;
begin
inherited Destroy;
end; { Destroy }
constructor TEoCEdit.Create(AOwner: TComponent);
{ Creates an object of type TEoCEdit, and initializes properties. }
begin
inherited Create(AOwner);
{ Initialize properties with default values: }
FAlignment := taLeftJustify;
end; { Create }
procedure TEoCEdit.CreateParams(var Params: TCreateParams);
const
Alignments: array[TAlignment] of WORD = (ES_LEFT, ES_RIGHT, ES_CENTER);
begin
inherited CreateParams(Params);
Params.Style := Params.Style or Alignments[FAlignment];
end;
procedure Register;
begin
RegisterComponents('EoC', [TEoCEdit]);
end; { Register }
end.