formating the variables in a dialog box

How do I make the values appearing in the dialog box for variables dlg.m_edit3 and dlg.m_edit4 show only upto 3 significant variables inside of more than 5-6 significant variables it is now showing (the code is shown below) ... What do I need to change in the code below ...

Thanks




// ******
 void CRms_VoltageView::OnLButtonUp(UINT nFlags, CPoint point)
 {
      // TODO: Add your message  handler code here and/or call default
      
     // Dialog Box No. 2
      CdlgDialog2 dlg;

      if (m_bDraw)
      {
// ??????????? this is where the
// problem is ?????????????

dlg.m_edit3 = (float)pline_array[current_line].fin_volt;
dlg.m_edit4 = (float)pline_array[current_line].fin_time;

if (dlg.DoModal() == IDOK)
            {            
                 .....
                }
arindam042099Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chensuCommented:
Associate the edit controls with CString member variables instead of float member variables, which I guess you are currently using. Thus, you can call the CString::Format as follows.

dlg.m_edit3.Format(_T("%.3f"), pline_array[current_line].fin_volt);
dlg.m_edit4.Format(_T("%.3f"), pline_array[current_line].fin_time);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arindam042099Author Commented:
Thanks
Once the values that are in pline_array[current_line].fin_volt and pline_array[current_line].fin_time are assigned to dlg.m_edit3,dlg.m_edit4 I want to change that (shown in the code) and then use then variables (will now need them to be in float) for calculations,... How can I convert them here to floats ???

 m_Setvolt = dlg.m_edit3;
 m_Tracetime =(float) ((int)((dlg.m_edit4/Half_Period)+(float) 0.5)* Half_Period);    
0
chensuCommented:
You may use the C Run-time Library functions _tcstod(strtod, wcstod) to convert strings to a double-precision value.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

arindam042099Author Commented:
can I use atof also .... what will be the difference between the two .. does atof convert CString member variables

THANKS
0
arindam042099Author Commented:
why is it I cannot format a float member variables to show 3 significant digits when my dialog box pops up ... and is so what is the code to do that ..
thanks
0
chensuCommented:
atof does it as well. The only difference is that strtod returns a pointer to character that stops scan.

I don't understand your last comment.
0
arindam042099Author Commented:
What I meant was why convert to string and then convert from string to float .. why cannot I use float all the way and only use formating to display into the dialog box ...
0
chensuCommented:
Because an edit control accepts strings only and there is no function to format a float number into an edit control.
0
arindam042099Author Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.