I wonder whether I can justify the text when I type inside a TEdit...
The default setting is left to Right But I would like to change it to Right
To Left.
I saw BiDiMode property ... but I didn't Understand... Could Somebody
Help me..
Thanks a lot .
Paulo.
BiDiMode is for languages like Hebrew that are written from right to left. If
you just want a right-aligned TEdit use this one, it has an Alignment
property like a TMemo. You have to install this unit into your component
palette.
unit AlignedEdit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TAlignedEdit = class(TEdit)
private
fAlignment: TAlignment;
procedure SetAlignment(const Value: TAlignment);
procedure WMGetDlgCode(var Message: TWMGetDlgCode); message
WM_GETDLGCODE;
procedure WMChar( Var Message: TMessage ); Message WM_CHAR;
{ Private declarations }
protected
{ Protected declarations }
Procedure CreateParams( Var params: TCreateParams ); override;
public
{ Public declarations }
published
{ Published declarations }
property Alignment: TAlignment read fAlignment write SetAlignment
default taLeftJustify;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('PBGoodies', [TAlignedEdit]);
end;
{ TAlignedEdit }
procedure TAlignedEdit.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 * DWORD(Ord( FAlignment <> taLeftJustify));
end;
procedure TAlignedEdit.SetAlignment(const Value: TAlignment);
begin
If fAlignment <> Value Then Begin
fAlignment := Value;
RecreateWnd;
End;
end;
procedure TAlignedEdit.WMGetDlgCode(var Message: TWMGetDlgCode);
begin
inherited;
Message.Result := Message.Result and not DLGC_WANTALLKEYS;
end;
procedure TAlignedEdit.WMChar(var Message: TMessage);
var
f: TForm;
begin
If Message.wparam = 13 Then Begin
f:= TForm(GetParentForm( self ));
If Assigned(f) Then
f.Perform( CM_DIALOGKEY, VK_RETURN, message.lparam );
End
Else
inherited;
end;
end.
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
I want to say tanks.. For you help ... It was exacty what I need.. I
didn't understand all the source code.. But I will
I appreciate it.
Paulo.
It's automatic, the only problem that may be related to yours i'm aware of is one
with multiline edit controls (TMaskEdit and TDBEdit are really multiline edits!):
if the controls client area is not high enough to display a line of text without
clippping the control will not display anything. Should be no problem as long as
you have AutoSize set to true (the default) for your edits.