I need to pass a pointer to an std::string as the LPARAM of a WM_USER message and get the string or char* in the WM_USER message handler of the main window.
How do I do that ?
What I am doing now (which is incorrect, since its not producing the result it should):
PostMessage(hwnd, LP_DOWNLOADUPDATE, (WPARAM)hHandleToWindow, (LPARAM)&remSize);
Where remSize is a sdt::string remSize; a global variable.
And in the message handler I am doing :
SetWindowText( (HWND)wParam, (char*)lParam );
Just must get a C-style string, i.e. a pointer to a zero-terminated array of characters:
Make sure
remSizedoesn’t go out of scope until you can be sure that the message has been processed, or else there will be dangling pointer.