Zitat:
Bei der TAlignEdit geht das nicht, egal was ich mach. Es stellt sich immer auf 27 Pixel zurück.
Hi,
Habe die Komponente noch ein wenig abgeändert.
Sollte somit das Problem mit der Höhe behoben sein.
Delphi-Quellcode:
unit AlignEdit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
TAlignEdit =
class(TEdit)
private
{ Private-Deklarationen }
FAlignment: TAlignment;
procedure SetAlign(
const Value: TAlignment);
procedure WMChar(
var Msg:TWMKey);
message WM_CHAR;
procedure WMSetFocus(
var Msg: TWMSetFocus);
message WM_SETFOCUS;
protected
{ Protected-Deklarationen }
procedure CreateParams(
var Params: TCreateParams);
override;
public
{ Public-Deklarationen }
constructor Create(AOwner: TComponent);
override;
published
{ Published-Deklarationen }
property Alignment: TAlignment
read FAlignment
write SetAlign
default taLeftJustify;
end;
procedure Register;
implementation
constructor TAlignEdit.Create(Aowner: TComponent);
begin
inherited Create(AOwner);
FAlignment := taLeftJustify;
end;
procedure TAlignEdit.SetAlign(
const Value: TAlignment);
begin
if FAlignment <> Value
then
begin
FAlignment := Value;
RecreateWnd;
end;
end;
procedure TAlignEdit.CreateParams(
var Params: TCreateParams);
const
Styles :
Array [TAlignment]
of DWORD = (ES_LEFT, ES_RIGHT, ES_CENTER );
begin
inherited;
Params.style := Params.style
or Styles[FAlignment]
or
ES_MULTILINE * Ord(FAlignment <> taLeftJustify);
end;
procedure TAlignEdit.WMChar(
var Msg: TWMKey);
var
key: Char;
begin
if Msg.CharCode = VK_RETURN
then
begin
key := #13;
if Assigned(OnKeyPress)
then
OnKeyPress(Self,key);
Msg.CharCode := 0;
end;
end;
procedure TAlignEdit.WMSetFocus(
var Msg: TWMSetFocus);
begin
inherited;
SelectAll;
end;
procedure Register;
begin
RegisterComponents('
Standard', [TAlignEdit]);
end;
end.