Solved

how to align an edit box...

Posted on 2001-09-16
3
228 Views
Last Modified: 2010-04-06
Hi Guys...

Im writing a simple calculator program. How I can align to the right the edit box like in the windows calculator?

Any ideas?

best regards,
Manuel Lopez (lopem)
0
Comment
Question by:lopem
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 6486208
hi lopem,
heres the way to add the Alignment settings :
 

unit AlignEdit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls;

type
  TEditAlign = class(TEdit)
  private
    { Private declarations }
  f_alignment: TAlignment;
  protected
    { Protected declarations }
    procedure CreateParams(var params:TCreateParams); override;
  procedure SetAlignment(value: TAlignment);
 public
    { Public declarations }
constructor Create(AOwner: TComponent); override;
  published
    { Published declarations }
 property Alignment:TAlignment read f_alignment write SetAlignment;
 
  end;

procedure Register;

implementation
constructor TEditAlign.Create(AOwner: TComponent);
begin
  inherited create(AOwner);
  end;

procedure TEditAlign.SetAlignment(value: TAlignment);
begin
  if value<>f_alignment then begin
    f_alignment:=value;
    recreatewnd;
    end;
  end;

procedure TEditAlign.CreateParams(var params:TCreateParams);
const
    Alignments : array[TAlignment] of Longint = (ES_LEFT, ES_RIGHT, ES_CENTER);
begin
 inherited CreateParams(Params);
 Params.Style := Params.Style or Alignments[F_Alignment] or ES_MULTILINE;
  end;
procedure Register;
begin
  RegisterComponents('Samples', [TEditAlign]);
end;

end.
0
 
LVL 17

Expert Comment

by:inthe
ID: 6486210
that will give access to alignment property via object inspector or via code ie:

procedure TForm1.FormCreate(Sender: TObject);
begin
 EditAlign1.Alignment := taRightJustify;
// EditAlign1.Alignment := taLeftJustify;
// EditAlign1.Alignment := taCenter;
end;
0
 
LVL 3

Author Comment

by:lopem
ID: 6486213
wow!

what a fast respond!

Thank you

Manuel Lopez (lopem)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now