Q&A

  • 컴포넌트를 만들어 보려고 하거든요?
Tedit 에서 상속받아서 글짜 정렬을 추가하려고 하거든요


unit Edit1;

interface

uses
  windows, Messages, SysUtils, Classes, Graphics, Controls, Dialogs,
StdCtrls, Mask;

type
  TAlignment = (taLeftJustify, taRightJustify, taCenter);

type
  TEdit1 = class(TEdit)
  private
    { Private declarations }
    FTextAlign: TAlignment;
    FAlignment: TAlignment;
    procedure SetAlignment(Value: TAlignment);
  protected
    { Protected declarations }


  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
  published
    { Published declarations }
    property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;

  end;

procedure Register;

implementation

uses StrUtils;


procedure Register;
begin
  RegisterComponents('test', [TEdit1]);
end;

constructor TEdit1.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FTextAlign := taLeftJustify; // 초기텍스트정렬은 왼쪽
end;

procedure TEdit1.SetAlignment(Value: TAlignment);
var
  FRect: TRect;
  AStyle:Integer;
begin
  if FAlignment <> Value then
  begin
    FAlignment := Value;
    RecreateWnd;
  end;
end;

이런식으로 했거든요
여기서 뭐를 더 추가해야하는 건가요?
고수님들 부탁드립니다.
0  COMMENTS