Edit-Mostrando da direita para a esquerda
Olá amigos,
Como fazer que um Edit inicie o foco da direita para a esquerda?
Como fazer que um Edit inicie o foco da direita para a esquerda?
Rodolpho123
Curtidas 0
Respostas
Anorex
22/03/2004
olá.... acho que o q vc quer é isso:
unit EditStrings;
interface
uses
Windows, SysUtils, Classes, Controls, StdCtrls;
type
TEditStrings = class(TEdit)
private
FAlinhamento : TAlignment;
Procedure SetAlinhamento(const Value: TAlignment);
protected
Procedure CreateParams(var Params: TCreateParams); override;
procedure KeyPress(var Key: Char); override;
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
published
Property Alinhamento: TAlignment Read FAlinhamento Write SetAlinhamento;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents(´Anorex´, [TEditStrings]);
end;
constructor TEditStrings.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
end;
destructor TEditStrings.Destroy;
begin
inherited destroy;
end;
procedure TEditStrings.KeyPress(var Key: Char);
begin
inherited;
if not (Key in [´a´..´z´,´A´..´Z´,#8,13,´ ´]) then
Key := 0;
end;
Procedure TEditStrings.CreateParams(var Params: TCreateParams);
Const Alinhamentos: Array [TAlignment] Of Longint = (ES_LEFT, ES_RIGHT, ES_CENTER);
Begin
Inherited CreateParams(Params);
Params.Style := Params.Style Or Alinhamentos[FAlinhamento];
End;
Procedure TEditStrings.SetAlinhamento(Const Value: TAlignment);
Begin
FAlinhamento := Value;
RecreateWnd
End;
end.
isso é o código de um componente derivado do tedit.... e faz o que vc quer...
unit EditStrings;
interface
uses
Windows, SysUtils, Classes, Controls, StdCtrls;
type
TEditStrings = class(TEdit)
private
FAlinhamento : TAlignment;
Procedure SetAlinhamento(const Value: TAlignment);
protected
Procedure CreateParams(var Params: TCreateParams); override;
procedure KeyPress(var Key: Char); override;
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
published
Property Alinhamento: TAlignment Read FAlinhamento Write SetAlinhamento;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents(´Anorex´, [TEditStrings]);
end;
constructor TEditStrings.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
end;
destructor TEditStrings.Destroy;
begin
inherited destroy;
end;
procedure TEditStrings.KeyPress(var Key: Char);
begin
inherited;
if not (Key in [´a´..´z´,´A´..´Z´,#8,13,´ ´]) then
Key := 0;
end;
Procedure TEditStrings.CreateParams(var Params: TCreateParams);
Const Alinhamentos: Array [TAlignment] Of Longint = (ES_LEFT, ES_RIGHT, ES_CENTER);
Begin
Inherited CreateParams(Params);
Params.Style := Params.Style Or Alinhamentos[FAlinhamento];
End;
Procedure TEditStrings.SetAlinhamento(Const Value: TAlignment);
Begin
FAlinhamento := Value;
RecreateWnd
End;
end.
isso é o código de um componente derivado do tedit.... e faz o que vc quer...
GOSTEI 0