Solved

Right Align Edit Boxes

Posted on 2003-11-04
7
517 Views
Last Modified: 2010-04-05
Can anyone please help me.  I am having extreme diffuculty with right aligning edit boxes.  

I have an app that uses numbers and it is very frustrating that I can't have my decimal places lined up to the right of an edit box in Delphi.  Very frustrating considering Delphi is such a great language.  You can do it with no problems in VB.  

Can anyone help me and tell me what I need to do?  I am not overly experienced so detailed help would be awesome!  A great answer will mean an increase in points.  Just want to get it done.

Thanks in advance.
Boss.
0
Comment
Question by:nzboss
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9684589
from barry (inthe):

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.

meikl ;-)
0
 
LVL 17

Accepted Solution

by:
geobul earned 300 total points
ID: 9685249
Hi,

I recommend you to try some of the free components from http://www.torry.net/diffedits.htm
TFloatEdit for example.

Regards, Geo
0
 

Author Comment

by:nzboss
ID: 9696696
Hi kretzschmar,

How would you go about using this code in an application?

Thanks,
Boss.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 9696718
its a component just install it into delphi-ide-component-palette,
and use it like a TEdit

meikl ;-)
0
 
LVL 1

Expert Comment

by:JackNaif
ID: 9707379
The first programme I ever wrote in Delphi was a simple calculator. I run right into this same problem. I suffered on it for a couple of days and then my teacher surprised me with an (unusally) wise answer:

"It doesn't matter what it *is*, but what it *looks like*. Use a TLabel with it's color property set to white, inside a slightly bigger TPanel with it's BevelOuter set to bvLower. Put the numbers in the Caption of the label, and use the alignment property of the label to have it align numbers to the right".

There is still a little bit of a nuisance to this solution: letting the user type or edit the numbers is a bit cumbersome, but it might still be a good solution. It worked for me. =)

Jack
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 9813555
Any update here, nzboss?
0
 

Author Comment

by:nzboss
ID: 9835291
Thanks got on component that works.  Just a shame that Delphi doesn't have this already built in.  CRAZY!

Boss.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

690 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