Solved

Visual C++ - Edit Box & variable precision

Posted on 1997-06-21
1
246 Views
Last Modified: 2012-05-04
In Visual C++ 4.0, I have created 4 edit boxes and placed
 them on a dialog box. I have assigned a floating point
variable to each edit box. Next to each box I have a radio
button. By checking the radio button for one of the edit
 boxes, the relevant edit box will become disabled.
By changing the values of the other three edit boxes the
disabled box's value will change. The problem is how do
I change the amount of decimal places displayed in the
disabled edit box. I would also like to change the color
of the result if it goes out of range.
0
Comment
Question by:robvg
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 1164015
You can convert a floating point variable to a string by using ::_ecvt(), ::_fcvt(), ::_gcvt(), ::wsprintf() with which you can determine the precision you want. In order to change the color of the edit box, you need to process WM_CTLCOLOR in your own edit box class or ON_WM_CTLCOLOR_REFLECT() in your own dialog class. See MFC Technical Notes: TN062: Message Reflection for Windows Controls.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Modify static variables within a class in VC++ 3 95
Prototype for MessageDlg in Embacadero XE 2 2 35
Best book to learn C++ 4 70
White board coding practice 3 79
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

910 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

21 Experts available now in Live!

Get 1:1 Help Now