whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

49 Visitors Online


 
...create a TEdit with definable text alignment?
Autor: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch
[ Print tip ]  

Tip Rating (19):  
     


{
  Dazu müssen die CreateParams von der Klasse TEdit überschrieben werden.
  Folgende Unit kann als Komponente installiert werden.

  All you have to do is to verride the CreateParams of the class TEdit.
  Install the following unit as a component.
}

unit AlignEdit;

interface

uses
  
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type

  
TAlign = (eaLeft, eaCenter, eaRight);

  TAlignEdit = class(TEdit)
  private
    
{ Private-Deklarationen }
    
FAlign: TAlign;
    procedure SetAlign(const Value: TAlign);
  protected
    
{ Protected-Deklarationen }
    
procedure CreateParams(var Params: TCreateParams); override;
  public
    
{ Public-Deklarationen }
    
constructor Create(AOwner: TComponent); override;
  published
    
{ Published-Deklarationen }
    
property Alignment: TAlign read FAlign write SetAlign default eaLeft;
  end;

procedure Register;

implementation

constructor 
TAlignEdit.Create(Aowner: TComponent);
begin
  inherited 
Create(AOwner);
  FAlign := eaLeft;
end;

procedure TAlignEdit.SetAlign(const Value: TAlign);
begin
  if 
FAlign <> Value then
  begin
    
FAlign := Value;
    RecreateWnd;
  end;
end;

procedure TAlignEdit.CreateParams(var Params: TCreateParams);
begin
  inherited
;
  case FAlign of
    
eaLeft: Params.Style   := Params.Style or ES_LEFT;
    eaCenter: Params.Style := Params.Style or ES_CENTER;
    eaRight: Params.Style  := Params.Style or ES_RIGHT;
  end;
end;

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

end.


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners