I would like to display an int value in a win32 MessageBox. I have read some different methods to perform this cast. Can someone provide me with a good implementation.
New to Win32 programming so go easy 🙂
update
So this is what i have so far. It works.. but the text looks like Chinese or some other double byte characters. I am not groking the Unicode vs. not Unicode types. Can someone help me understand where I am going wrong?
int volumeLevel = 6;
std::stringstream os;
os<<volumeLevel;
std::string intString = os.str();
MessageBox(plugin.hwndParent,(LPCTSTR)intString.c_str(), L"", MB_OK);
LPCTSTRis defined like this:std::string::c_str()returns aconst char*only. You can’t convert aconst char*directly toconst wchar_t*. Normally the compiler will complain about it, but with theLPCTSTRcast you end up forcing the compiler to shut up about it. So of course it doesn’t work as you expect at runtime. To build on what you have in your question, what you probably want is something like this: