64,649
社区成员
发帖
与我相关
我的任务
分享
HWND hWnd = ::FindWindow(NULL , "MsgRecv");
Test x;
x.x = 1;
x.y = 2;
::SendMessage(hWnd , WM_USER_MESSAGE , 0 , (LPARAM)&x);
LRESULT CMsgRecvDlg::ShowMessage(WPARAM wParam,LPARAM lParam)
{
Test* m = (Test*)lParam;
int x = m->x; //此处不知道为什么总是为0
int y = m->y; //同上
return 1;
}
struct Test
{
int x ;
int y ;
};
LRESULT CMsgRecvDlg::ShowMessage(WPARAM wParam,LPARAM lParam) //获取消息
{
Test *x = (Test*)lParam;
int m = x->x;
int n = x->y;
return 1;
}
Test *px = new Test;
px->x = 4;
px->y = 5;
::SendMessage(hWnd , WM_USER_MESSAGE , 0 ,(LPARAM)px);
BOOL CMsgRecvDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{
Test *x = (Test*)pCopyDataStruct->lpData;
int m = x->x;
int n = x->y;
return TRUE;
}
HWND hWnd = ::FindWindow(NULL , "MsgRecv");
Test x;//临时变量,要用new
x.x = 1;
x.y = 2;
::SendMessage(hWnd , WM_USER_MESSAGE , 0 , (LPARAM)&x);
HWND hWnd = ::FindWindow(NULL , "MsgRecv");
Test* px=new Test;
px->x = 1;
px->y = 2;
::SendMessage(hWnd , WM_USER_MESSAGE , 0 , (LPARAM)px);
//发送
//set up a COPYDATASTRUCT structure for use with WM_COPYDATA
cpData.dwData = (DWORD) nLevel;
cpData.cbData = strlen(szBuffer) + 1;
cpData.lpData = szBuffer;
//send the structure to Debug via the system
LRESULT lResult = ::SendMessage(hWnd, WM_COPYDATA, (UINT) NULL, (long) &cpData);
//接收消息
BOOL CXXxDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)