Title: Right-aligned Edit Field (Merry Christmas)
Question: Just a little component to right-align your edit field.
Answer:
Hi folks,
it#s christmas eve and I have a little component for all of you - didn't find one here on D3K. I hope you can use it. It is a edit field, as all of you know, allowing you to right-align the text contained. Save the unit as uEditEx.pas and add it to your Component bar (component menu - add component)
HERE IT GOES
============
unit uEditEx;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TEditEx = class(TEdit)
private
FAlignment: TAlignment;
procedure SetAlignment(const Value: TAlignment);
protected
procedure CreateParams(var Params: TCreateParams); override;
public
published
constructor Create(AOwner: TComponent); override;
property Alignment: TAlignment
read FAlignment
write SetAlignment
default taLeftJustify;
end;
procedure Register;
implementation
{R uEditEx.dcr}
procedure Register;
begin
RegisterComponents('gate(n)etwork', [TEditEx]);
end;
{ TEditEx }
constructor TEditEx.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FAlignment := taLeftJustify;
end;
procedure TEditEx.CreateParams(var Params: TCreateParams);
const
Alignments: array[TAlignment] of Cardinal =
(ES_LEFT, ES_RIGHT, ES_CENTER);
begin
inherited CreateParams(Params);
Params.Style := Params.Style or {ES_MULTILINE or} Alignments[FAlignment];
end;
procedure TEditEx.SetAlignment(const Value: TAlignment);
begin
if FAlignment Value then
begin
FAlignment := Value;
RecreateWnd;
end;
end;
end.
Ciao and merry christmas,
Daniel
gate(n)etwork