Doubles in Edit Boxes

Started by
4 comments, last by Darkor 22 years, 2 months ago
I need to display doubles in win32 edit boxes as well as retrive them. In the books I''ve read, there is only four methods to do this:
  
GetDlgItemText(...)
SetDlgItemText(...)
GetDlgItemInt(...)
SetDlgItemInt(...)
  
Since I need doubles, how would I display them and retrive them? I thought of converting it to text and then back again to doubles but this is not what I had in mind. However, if this is the only way to do it, kindly direct me to the functions needed to do this. Thanks!
Advertisement
Look up sprintf().
quote:Original post by SabreMan
Look up sprintf().


I doubt if you understand what my problem is. Please read carefully. I know what sprintf() does; it prints text to a string. How does this help? Please elaborate. Your short posts serves only to insult my intelligence. =(

By edit boxes, I mean windows edit boxes such as the Name and Password fields when you startup windows.

How do I retrive doubles from edit boxes.

Edited by - Darkor on February 22, 2002 11:04:05 AM
Try atof(). It converts ascii strings to floating point variables.
You will have to interpret the doubles as a string in both the Get and Set methods.

As SabreMan said, "Look up sprintf()"
sprintf is used like this
        double myNumber = 65.37326;    char temp[ 64 ];    sprintf( temp, "%.6f", myNumber ); // 6 decimal places for the number    SetDlgItemText(..., myNumber, ... );  


To retrieve you would interpret the text as a number and use "atof" to convert it to a double


Edited by - The Bear on February 22, 2002 11:16:34 AM
Okay thanks!

Anyway, I was looking for a specific function that deals with the edit box itself.

But thanks anyway. I already know how to use sprintf and atof.

This topic is closed to new replies.

Advertisement