formatting output in control box
-
Hi...I'm developing a graphical interface. The programs computes some values that are later shown in control boxes in the screen. The program does already that, but I was wondering if there is any way to format that output. That is if the program is displaying in a control box a numeric variable it shows 99.9999 and not 99.999999 (or whatever). I'm using MFC to do most of the stuff, like showing and reading, and all the computations are mine. In the part where the values are shown, I'm calling UPDATE() with false, so to not read values, just show the values. Thanks, Eric Manuel Rosales Pena Alfaro PhD student Unversity of Essex Wivenhoe Park Colchester, CO4 3SQ Essex, Uk email: emrosa@essex.ac.uk tel: +44-01206-87311
-
Hi...I'm developing a graphical interface. The programs computes some values that are later shown in control boxes in the screen. The program does already that, but I was wondering if there is any way to format that output. That is if the program is displaying in a control box a numeric variable it shows 99.9999 and not 99.999999 (or whatever). I'm using MFC to do most of the stuff, like showing and reading, and all the computations are mine. In the part where the values are shown, I'm calling UPDATE() with false, so to not read values, just show the values. Thanks, Eric Manuel Rosales Pena Alfaro PhD student Unversity of Essex Wivenhoe Park Colchester, CO4 3SQ Essex, Uk email: emrosa@essex.ac.uk tel: +44-01206-87311
-
Hi...I'm developing a graphical interface. The programs computes some values that are later shown in control boxes in the screen. The program does already that, but I was wondering if there is any way to format that output. That is if the program is displaying in a control box a numeric variable it shows 99.9999 and not 99.999999 (or whatever). I'm using MFC to do most of the stuff, like showing and reading, and all the computations are mine. In the part where the values are shown, I'm calling UPDATE() with false, so to not read values, just show the values. Thanks, Eric Manuel Rosales Pena Alfaro PhD student Unversity of Essex Wivenhoe Park Colchester, CO4 3SQ Essex, Uk email: emrosa@essex.ac.uk tel: +44-01206-87311
You can use
std::stringstream ss;
ss << std::setprecision(4) << YourVariable
m_Editbox.SetWindowText( ss.str().c_str() );You can look up the other modifiers beside std::setprecision() in the Help. There is one for any need. Or you simply use the old-fashioned way, from the days before C++ :
sprintf()
or its wrapper in the CString class,Format()
.
My opinions may have changed, but not the fact that I am right.