Solved

right justify number in a CEdit

Posted on 1998-05-12
4
515 Views
Last Modified: 2013-11-20
I've got a CDaoRecordView form -- one of the fields of which
is a CEdit displaying a COleCurrency value stored in the
recordset.  No problem...except that I would like the value
to be right-justified.  

Neither the "Align Text" style, nor the "Right align text"
extended style seem to work.  The help says this working depends
on the window's style...  Can't find anything in the online help,
codeguru, etc.. about right aligning a number in a CEdit.  I
even compiled up a bunch of the likely sample projects, but of
course, I can't find even one field with a number that is right-
aligned.

What direction do I go here?  Surely I don't pad the string with
spaces...aren't the characters different widths?

Do I override the control's OnDraw function or something?  I can
see constructing the string, then getting its display width,
subtracting that from the field width, and drawing the number
in the right place.  But that seems like I must be re-inventing
the wheel.

Help!
0
Comment
Question by:rstout
  • 2
4 Comments
 

Expert Comment

by:javan
ID: 1310087
Make sure the style is applied before it is created.  ModifyStyle doesn't change it.  When you place the control on the CFormView derived class in the resource editor, apply the options there and it should be right aligned.
0
 

Author Comment

by:rstout
ID: 1310088
I did applied the right-align style in the resource editor.  Here is the line from the rc file for it:

    EDITTEXT        IDC_PRICE,58,69,40,14,ES_RIGHT | ES_NUMBER,WS_EX_RIGHT

It still doesn't right align.  What's wrong?
0
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 1310089
On Windows NT 5.0 and later, Windows 98 and later, ES_RIGHT right-aligns text in a single-line or multiline edit control. But on earlier versions of Windows and Windows NT, it right-aligns text only in a multiline edit control. So, you have to make it a multiline edit control.
0
 

Author Comment

by:rstout
ID: 1310090
That was the secret.  Whew!  I knew someone had the answer.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Perl Awk Need Help 3 116
VBA "SendKeys" Syntax for Multiple Keystrokes 7 108
changeXy challenge 13 82
Capture logon name 13 73
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

776 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