Ver Mensaje Individual
  #3  
Antiguo 19-03-2008
Avatar de MAXIUM
MAXIUM MAXIUM is offline
Miembro
 
Registrado: may 2005
Posts: 1.490
Reputación: 21
MAXIUM Va camino a la fama
El enlace esta roto pero aquí el código:

Página del autor: Roman
Código Delphi [-]
unit AlignEdit;

interface

uses
  Windows, Classes, Controls, StdCtrls;

type
  TAlignEdit = class(TEdit)
  private
    FAlignment: TAlignment;
    procedure SetAlignment(const Value: TAlignment);

  protected
    procedure CreateParams(var Params: TCreateParams); override;

  public
    constructor Create(AOwner: TComponent); override;

  published
    property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
  end;

procedure Register;

implementation

constructor TAlignEdit.Create(AOwner: TComponent);
begin
  inherited;
  FAlignment := taLeftJustify;
end;

procedure TAlignEdit.CreateParams(var Params: TCreateParams);
begin
  inherited;

  case FAlignment of
    taLeftJustify: Params.Style := Params.Style or ES_LEFT;
    taRightJustify: Params.Style := Params.Style or ES_RIGHT;
    taCenter: Params.Style := Params.Style or ES_CENTER;
  end;
end;

{
  El estilo ES_XXX se usa al crear una ventana de manera que al cambiar
  aquel debemos "rehacer" la ventana con RecreateWnd.
}
procedure TAlignEdit.SetAlignment(const Value: TAlignment);
begin
  if FAlignment <> Value then
  begin
    FAlignment := Value;
    RecreateWnd;
  end;
end;

procedure Register;
begin
  RegisterComponents('Samples', [TAlignEdit]);
end;

end.
Responder Con Cita