Link to home
Start Free TrialLog in
Avatar of arindam042099
arindam042099

asked on

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)
            {            
                 .....
                }
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of arindam042099
arindam042099

ASKER

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);    
You may use the C Run-time Library functions _tcstod(strtod, wcstod) to convert strings to a double-precision value.
can I use atof also .... what will be the difference between the two .. does atof convert CString member variables

THANKS
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
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.
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 ...
Because an edit control accepts strings only and there is no function to format a float number into an edit control.
thanks