Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
Right-align the content of a TEdit Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
27-Aug-02
Category
VCL-General
Language
Delphi All Versions
Views
146
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to right-align the content of a TEdit

Answer:

Solve 1:
1   
2   procedure TESBPCSCustomEdit.CreateParams(var Params: TCreateParams);
3   begin
4     inherited CreateParams(Params);
5     case Alignment of
6       taLeftJustify: Params.Style := Params.Style or ES_LEFT;
7       taRightJustify: Params.Style := Params.Style or ES_RIGHT or ES_MultiLine;
8       taCenter: Params.Style := Params.Style or ES_CENTER or ES_MultiLine;
9     end;
10    if FReadOnly then
11      Params.Style := Params.Style or ES_READONLY;
12  end;



Solve 2:

13  unit uEditEx;
14  
15  interface
16  
17  uses
18    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
19    StdCtrls;
20  
21  type
22    TEditEx = class(TEdit)
23    private
24      FAlignment: TAlignment;
25      procedure SetAlignment(const Value: TAlignment);
26    protected
27      procedure CreateParams(var Params: TCreateParams); override;
28    public
29    published
30      constructor Create(AOwner: TComponent); override;
31      property Alignment: TAlignment
32        read FAlignment
33        write SetAlignment
34        default taLeftJustify;
35    end;
36  
37  procedure register;
38  
39  implementation
40  
41  {R uEditEx.dcr}
42  
43  procedure register;
44  begin
45    RegisterComponents('gate(n)etwork', [TEditEx]);
46  end;
47  
48  { TEditEx }
49  
50  constructor TEditEx.Create(AOwner: TComponent);
51  begin
52    inherited Create(AOwner);
53    FAlignment := taLeftJustify;
54  end;
55  
56  procedure TEditEx.CreateParams(var Params: TCreateParams);
57  const
58    Alignments: array[TAlignment] of Cardinal =
59    (ES_LEFT, ES_RIGHT, ES_CENTER);
60  begin
61    inherited CreateParams(Params);
62    Params.Style := Params.Style or {ES_MULTILINE or}  Alignments[FAlignment];
63  end;
64  
65  procedure TEditEx.SetAlignment(const Value: TAlignment);
66  begin
67    if FAlignment <> Value then
68    begin
69      FAlignment := Value;
70      RecreateWnd;
71    end;
72  end;
73  
74  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC