How to send CString with SendMessage
-
Hi all, does anybody know what the exact syntax is for sending a CString variable with SendMessage? I have tried every thing you can imagine: UINT MyThread(LPVOID arg) { HWND hMain = (HWND) arg; CString text; text = "Hello"; SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM &) text); } LRESULT CMyDlg::OnSendHello(WPARAM wParam, LPARAM lParam) { CString* text = (CString *) lParam; return 0; } What is wrong with this code?
-
Hi all, does anybody know what the exact syntax is for sending a CString variable with SendMessage? I have tried every thing you can imagine: UINT MyThread(LPVOID arg) { HWND hMain = (HWND) arg; CString text; text = "Hello"; SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM &) text); } LRESULT CMyDlg::OnSendHello(WPARAM wParam, LPARAM lParam) { CString* text = (CString *) lParam; return 0; } What is wrong with this code?
-
Hi all, does anybody know what the exact syntax is for sending a CString variable with SendMessage? I have tried every thing you can imagine: UINT MyThread(LPVOID arg) { HWND hMain = (HWND) arg; CString text; text = "Hello"; SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM &) text); } LRESULT CMyDlg::OnSendHello(WPARAM wParam, LPARAM lParam) { CString* text = (CString *) lParam; return 0; } What is wrong with this code?
It appears you want to send a pointer to a CString. Wrong: SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM &) text); Right: SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM) &text); Personly I recommend sending the address of the string instead of the address of a CString object. SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM)(LPCSTR)text); Trust in the code Luke. Yea right!