VC中CString和WPARAM之间的相互转换

来源:互联网 发布:ubuntu mate安装jdk 编辑:程序博客网 时间:2024/06/05 20:38

在传递自定义消息的过程中,需要转换CString 变量。

在发送消息端使用如下方法:

SendMessage(WM_MESSAG_MINE,0,(LPARAM)strVal.AllocSysString());

----------------------------------------

在接收消息端使用:

BSTR b = (BSTR)lParam;
CString s(b);
SysFreeString(b);
AfxMessageBox(s);

即可。

参考了如下文章

http://forums.devx.com/archive/index.php/t-156023.html