Solved

right justify number in a CEdit

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now