Solved

right justify number in a CEdit

Posted on 1998-05-12
4
522 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

Industry Leaders: 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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

630 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