String between unmanaged and managed
- From: andrerus@xxxxxxxxx
- Date: 22 Sep 2006 08:37:21 -0700
Hi,
Some were I found this function:
LPCWSTR LPCSTR_2_LPCWSTR(const char* inString)
{
int len = strlen(inString) + 1;
wchar_t *outString = new wchar_t[len];
mbstowcs(outString, inString, len);
return (LPCWSTR) outString;
}
Now I have to post a message containing text (as wParam) from an
unmanaged part to a managed one.
I do something like this:
#unmanaged1
PostMessage(destHwnd, myMsg, (WPARAM) LPCSTR_2_LPCWSTR("string"), 0);
#unmanaged2
....
LPSTR text = new char[256];
SendMessage(toolbarHwnd, TM_GETBUTTONTEXT, wID, text);
PostMessage(destHwnd, myMsg, (WPARAM) LPCSTR_2_LPCWSTR(text), 0);
#managed
....
string s = Marshal.PtrToStrUni(m.WParam);
In case unmanaged1 I always receive correct string, instead in case
unmanged2 never.
I'm becoming crazy!!!
Andrea
.
- Follow-Ups:
- Re: String between unmanaged and managed
- From: Paul G. Tobey [eMVP]
- Re: String between unmanaged and managed
- Prev by Date: ScrollWindowEX() question
- Next by Date: Re: Would I control the zoom in excel by program?
- Previous by thread: ScrollWindowEX() question
- Next by thread: Re: String between unmanaged and managed
- Index(es):