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
Solved

right justify number in a CEdit

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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 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.

840 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