可以设置对齐方式的Edit组件
{**
* 单元:FloatEdit
* 作者:网事如风
* 作用:可以设置对齐方式的Edit
* 使用:
**}
unit RightEdit;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls;
type
TRightEdit = class(TEdit)
private
FAlignment : TAlignment; //对齐方式
procedure SetAlignment(Value: TAlignment);
protected
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
published
property Alignment: TAlignment read FAlignment write SetAlignment;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyCompent', [TRightEdit]);
end;
procedure TRightEdit.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Case FAlignment of
taLeftJustify : Params.Style := Params.Style + ES_LEFT;
taRightJustify : Params.Style := Params.Style + ES_RIGHT;
taCenter : Params.Style := Params.Style + ES_CENTER;
end;
end;
procedure TRightEdit.SetAlignment(Value: TAlignment);
begin
if FAlignment <> Value then
begin
FAlignment := Value;
RecreateWnd;
end;
end;
end.