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
How to change the alignment for 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
08-Jun-03
Category
VCL-General
Language
Delphi 2.x
Views
49
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Mike Shkolnik

How can I change the alignment for my TEdit?

Answer:

Sometimes you need change the text alignment in standard TEdit component. For some 
reason the developers in Microsoft decided, that for data editing in single line we 
do not need to change alignment and haven't provided such possibility:( 

But sometimes I need it! For example, I like view a numbers with right alignment... 

If you need it too then this delphi tip for you:
 
1   type
2     TEditAlignment = class(TCustomEdit)
3     protected
4       { Protected declarations }
5       procedure CreateParams(var Params: TCreateParams); override;
6     end;
7   
8   procedure TEditAlignment.CreateParams(var Params: TCreateParams);
9   const
10    Alignments: array[TAlignment] of Longint =
11    (ES_LEFT, ES_RIGHT, ES_CENTER);
12  begin
13    inherited CreateParams(Params);
14  
15    Params.Style := Params.Style or ES_MULTILINE or
16      Alignments[FAlignment];
17  end;


In Windows 98 you can set a Params.Style without ES_MULTILINE flag and it too will 
work. 

Also after such edit control can't correctly work with PasswordChar <> #0 (but I 
think for password input it's not necessary to change alignment). 

PS: remark, that after that your TEdit is not "real" edit control - now is a 
control like "memo" but single line... Of course, you can use a standard TMemo 
component with height equal to one line. 

Component Download: http://www.geocities.com/mshkolnik/download/edittype.zip

			
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