[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

CDialog Class Member Variable precision

Posted on 1997-10-17
4
Medium Priority
?
275 Views
Last Modified: 2013-11-20
How do I set the precision for the variables.  Similar to iostream.setprecision, Fortran "FIX" etc.  I would like not to convert back and forth between types.  Can't find this info in my books or the CD-ROM online help.  Thanks for any help in this "simple" matter.
0
Comment
Question by:lucie
[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
 
LVL 3

Expert Comment

by:shaig
ID: 1308360
I don't understand what do CDialog members have to do with precision, and if they do, could you be more presice?

Anyway this is probably a C/C++ question:
the copnversion between types in C is automatic.
It is possible to set the precision when:
a) printing - sprintf or CString::Format.  example:
  sprintf( buffer, "The float value is: %8.2f", m_floatVarible );
b) inputing - scanf(), very simulare.

hope i helped.  : - {}
0
 

Author Comment

by:lucie
ID: 1308361
VC++ uses DDX/DDV to exchange data between the Dialog Control and the Member Variable.  In context:

m_floatVariable = sqrt(some_value);

When variable data sent back to the Dialog Control, the Dialog Box displays a number like 4.23592347575, when I'd like to see a number 4.24 or 4.236.  I've found that I can accomplish this by changing the type from "double" using the _fcvt function which allows you to control the # of digits after the decimal.  I'd just like to control rounding of the variable without changing types.  In fortran, I'd just FIX 2 or 3 and be done with it.  Just want to know if you can do this in VC++
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 200 total points
ID: 1308362
Write your own DDX routine (copy the MFC version or at least call it) and do your percision fixes there.

something like this ...

void AFXAPI DDX_Text_2DP(CDataExchange* pDX, int nIDC, float& value)
{
      if (pDX->m_bSaveAndValidate) {
            DDX_Text(pDC,nIDC,value);
      } else {
            CString buffer;
            HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC);
            buffer.Format("%.2f", value);
            ::SetWindowText(hWndCtrl, szBuffer);
      }
}

0
 

Author Comment

by:lucie
ID: 1308363
Thanks verrrrrrry much.

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

649 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