在我的工作线程中,我创建了一条发送到主对话框的消息。一旦主对话框收到消息并进入我的 OnStatusUpdate() 函数,我想从 LPARAM lParam 中提取消息并将其显示在对话框编辑框中。我得到的不是我的信息,而是垃圾。
UINT CGDC74xDlg::LeakTstThread( LPVOID pParam )
{
HWND *phObjectHandle = static_cast<HWND *>(pParam);
CString strTmp = "It works!";
CString * message = new CString(strTmp);
::PostMessage(*phObjectHandle, WM_LEAK_TEST_THREAD, 0, (LPARAM)message);
::Sleep(5000);
delete phObjectHandle;
return( 0 );
}
LRESULT CGDC74xDlg::OnStatusUpdate(WPARAM wParam, LPARAM lParam)
{
LPTSTR lpMessage = (LPTSTR)lParam;
CString s = lpMessage;
delete lpMessage;
GetDlgItem(IDC_EDIT_LEAK_TEST_RESULTS)->SetWindowText(s);
return 0;
}