Posted by Fox on 2000-04-24
> Hello, > I'm having a problem getting user input in C using the windows API. I've > created a dialog box, trying to get a velocity and angle from the user with > GetDlgItemText. Then using sscanf to get the float number out of it. And > then I'm trying to display the numbers in the WM_PAINT message. But it > doesn't work, I know that i'm getting a number, because the other functions > that use the number work fine. But I can't display the numbers, they just > end up as 0. Here's what I'm using to display the number: > > wsprintf(buffer, "Velocity = %li", Velocity); > TextOut(dc, 0, 0, buffer, strlen(buffer)); > > But this doesn't work, I'm not sure what to put where it says %li, %f > doesn't work. Cuz I need a float from the user. If anybody knows the > answer or has another solution I'm happy to hear from them. Thanks, see ya. /***************************************/ You are able to get just numbers from dialog box controls. You don't need to get a string and then parse it for the number! That is, if you're using an edit box; in which case you'd just set the edit box to "numbers only"(something to that effect) and extract the number from it. Since you're using the API, it will be a bit more difficult to get the number, as I can't remember how, exactly, to do that(I've been working with MFC for the last several months, so I'm a bit rusty on API). I don't know if this is true or not, but it's also possible that 'TextOut', 'wsprintf' and any like functions are converting the float to(pick one: scientific notation, integer, right of decimal only, information lost). I don't know exactly, I'd have to see the entire program. Hope this helped. /* Remember, complex problems almost always have simple solutions!
Previous post | Next post | Timeline | Home