procedure TJackEdit.SetAlignment(value: TAlignment);
begin
if value <> FAlignment then
begin
FAlignment := value;
RecreateWnd;
end;
end;
procedure TJackEdit.KeyPress(var Key: Char);
begin
if ksReturn in Keys then
begin
if Key = Chr(Vk_Return) then
begin
Key := Chr(0);
(Owner as TControl).Perform(wm_NextDlgCtl,0,0);
end;
end;
if ksEscape in Keys then
begin
if Key = Chr(Vk_Escape) then
begin
Key := Chr(0);
(Owner as TControl).Perform(wm_NextDlgCtl,1,0);
end;
end;
inherited KeyPress(Key);
end;
procedure TJackEdit.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
case Alignment of
taLeftJustify : Params.Style := Params.Style or (ES_LEFT or Es_MULTILINE);
taRightJustify : Params.Style := Params.Style or (ES_RIGHT or ES_MULTILINE);
taCenter : Params.Style := Params.Style or (ES_CENTER or Es_MULTILINE);
end;
end;
constructor TJackEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FAlignment := taLeftJustify;
end;
destructor TJackEdit.Destroy;
begin
inherited Destroy;
end;
procedure Register;
begin
RegisterComponents('Jack', [TJackEdit]);
end;
继承TEdit,重载CreateParams,修改Param即可。
procedure TEdit_Ex.CreateParams(var Params: TCreateParams);
begin
inherited;
if self.FTextOnRight then Params.Style:=Params.Style or ES_RIGHT;
end;