我的传递的参数定义为一个结构体,如下:
struct MsgParm
{
BSTR fromuserid;
BSTR fromuserclass;
BSTR touserid;
BSTR touserclass;
BSTR fromusername;
BSTR msg;
BSTR sendtime;
};
在ATL中发送消息过程如下:
HWND myhwnd=::FindWindow(NULL,titiename);
if(myhwnd!=NULL)
{
//::MessageBox(NULL,_T("发送消息"),_T("已经存在!"),MB_OK);
MsgParm parmstr;
parmstr.fromuserid=fromuserid;
parmstr.fromuserclass=fromuserclass;
parmstr.touserid=touserid;
parmstr.touserclass=touserclass;
parmstr.fromusername=fromusername;
parmstr.msg=msg;
parmstr.sendtime=sendtime;
::SendMessage(myhwnd,ON_UM_MYMSG,(WPARAM)&parmstr, (LPARAM)&parmstr);
我在MFC的exe程序中,接收消息时,
LRESULT CLgChatDialogDlg::OnMyMessage(WPARAM wParam, LPARAM lParam)
{
myParam1=(MsgParm*)lParam;
myParam2=(MsgParm*)wParam;
CString fromuserid=CString(myParam1->fromuserid);
CString fromuserclass=CString(myParam1->fromuserclass);
CString touserid=CString(myParam1->touserid);
CString touserclass=CString(myParam1->touserclass);
CString fromusername=CString(myParam1->fromusername);
CString msg=CString(myParam1->msg);
CString sendtime=CString(myParam1->sendtime);
}
可以收到消息,可以参数是空值或是乱码?请问如何定义这些参数,保证可以准确解析这些参数?