Solved

right justify number in a CEdit

Posted on 1998-05-12
4
518 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
[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
  • 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

Technology Partners: 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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa‚Ķ
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.

730 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