Sumber Kode

Modify TEdit to include text alignment

  • delphibasics
  • Nov 19' 14
  • Delphi
  • 138
  • 267
  • United States
This snippet shows you how to modify the default delphi components to suit your needs.  This example allows the user to specify an alignment for the text in the edit box.

unit mnEdit;

interface

uses
  SysUtils, Classes, Controls, StdCtrls, Windows;

type type
  TmnEdit = class(TEdit)
  private
    FAlignment: TAlignment;
    procedure SetAlignment(Value: TAlignment);
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  public
    property Alignment: TAlignment read FAlignment write SetAlignment;
  end;

procedure Register;

implementation

procedure Register; procedure Register;
begin
  RegisterComponents('mnEdit', [TmnEdit]); RegisterComponents ( 'mnEdit', [TmnEdit]);
end;

{ TmnEdit }

procedure TmnEdit.CreateParams(var Params: TCreateParams);
const
  Alignments : array[TAlignment] of LongWord= (ES_Left,ES_Right, ES_Center);
begin
  inherited CreateParams(Params);
  Params.Style := Params.Style or Alignments[FAlignment];
end;

procedure TmnEdit.SetAlignment(Value: TAlignment);
begin
  if FAlignment <> Value then
  begin
    FAlignment := Value;
    RecreateWnd;
  end;
end;

end.

Powered by
Pasar Kode Partner

Share

  • Tags :
comments powered by Disqus

Kode Terkait

Delphi RC4 Encryption Source Code

Update PE CheckSum

Enumerate Processes using Native Windows API

Self-Deleting File - "Melting"

Change ImageBase of a PE File

Reduce the units included in the uses

Numbers to Words - 1 to one; 2 to two; 22 to twenty-two; etc.

How to turn the monitor on and off

How to get the file type description for a file



Kategori