首页 新闻 赞助 找找看

ATL向MFC的exe程序发送自定义消息,如何传递参数?

0
[待解决问题]

我的传递的参数定义为一个结构体,如下:

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);

}

可以收到消息,可以参数是空值或是乱码?请问如何定义这些参数,保证可以准确解析这些参数?

C++
深山居士的主页 深山居士 | 初学一级 | 园豆:123
提问于:2012-09-24 09:41
< >
分享
所有回答(1)
0
Launcher | 园豆:45045 (高人七级) | 2012-09-24 09:46
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册