How do I pass a string variable to MessageBox()?

hello, I am having trouble finding the solution to printing the contents of a variable. Here is my code:

1
2
3
4
5
6
7
void OnSize(HWND hwnd, UINT flag, int width, int height)
{
	std::wstringstream ss (std::wstringstream::in | std::wstringstream::out);
	ss << flag;
	std::wstring myStr = ss.str();
	MessageBoxW(hwnd,myStr, L"Window Resized",NULL);
}


Note, I have #defined UNICODE at the beginning. The compiler tells me this for myStr.

1
2
std::wstring myStr
Error: No suitible conversion function from "std::wstring" to "LPCWSTR" exits


I would appreciate knowing what I'm not doing. =|
Last edited on
MessageBoxW(hwnd, myStr.c_str(), L"Window Resized", MB_OK);
Wow, that worked. Thanks.
Topic archived. No new replies allowed.