I'm trying to do something like a countdown timer where you set a time and start it, however I'm having strange problems with setting time, I have static control with "00:00:00" as base string, this is my code for setting time
from those "red debug dots" you can add at the left that will show you if code is running I've noticed that it stops at wsprintf, so it won't do SendMessage function
i'm not getting any errors at build or in debug output
if I add MessageBox after GetDlgItemText (in SetTimeDlgProc) it is returning string as it should, but if I add wsprintf there everything is fcked up and it stops working there too
I've tried to add sprintf and sprintf_s but same result..
after one of those and one of those strings (sHour, sMinute or sSecond), but that's not the problem, everything AFTER ANY sprintf function will stop working, so any sprintf function (wsprintf, sprintf, sprintf_s) is stopping my application...
Ah, I just noted the issue: You think you can pass a std::string object (a C++ object) to a C function like wsprintf(). You need to pass the return value of c_str(). It is called that for a reason: It returns a C string. C functions use C strings.
Well, that's weird now that I think about it. The C++ compiler should have complained about this. Are you sure that compiled for you? Soooo weird. Did you force something by typecasting?
I thought about this too, but I told myself that compiler should tell me it too since I HAVE to use .c_str() in, for example, GetDlgItemText, but it didn't tell me anything so I left it like it is, and yes, it's compiling without any errors or warnings
Right. Now that I remember, wsprintf() and related functions take those in the variable parameters, so no type checking there. So yes, use .c_str() and your problem will be solved.