Sign in to follow this  
Thomo

Floats and UpDown Controls

Recommended Posts

I'm trying to get some kind of windows control that will allow me to increment in fractions (floats). I tried trackbars but had no joy. Second attempt was to use updown boxes. The UD_ACCEL structure: typedef struct { UINT nSec; UINT nInc; } UDACCEL, *LPUDACCEL; expects an integer. I tried creating my own custom structure typedef struct { UINT nSec; float nInc; } UDACCEL2, *LPUDACCEL2; The compiler accepts it, but when I execute the app it increments with a strange value before crashing. Anyone know how I can increment in decimals (0.5) rather than ints or suggest a control that will allow me to do so. Thanks

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Convert the value to a float and divide it by some value before using it. For example if you want to increment by fourths, just imagine that the control is setting the number of fourths, then convert it into the actual units. 11 fourths = 11/4 = 2.75, like that.

Share this post


Link to post
Share on other sites
I am not sure this a control like this, but you could always just convert the integer into a float. If you wanted the values to be between 1.0f and 0.0f, you could just devide your integer by the maximum value.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this