Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Centrar el texto de un edit (https://www.clubdelphi.com/foros/showthread.php?t=28069)

Sayuri 07-12-2005 21:22:17

Centrar el texto de un edit
 
Buenas amigos,
Me gustaria poder conseguir que el texto de un edit estuviera centrado siempre que se escriba algo

¿Cómo se puede conseguir?

Un saludin

dec 07-12-2005 21:29:17

Hola,

El componente "TAlignEdit" escrito por roman puede ayudarte. ;)

MAXIUM 19-03-2008 21:28:59

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.


La franja horaria es GMT +2. Ahora son las 03:27:09.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi