我可以用对象发送消息吗? 类似的东西:
myClass *myObj = new myClass();
pDlg->SendMessage(MyEvent, NULL, (LPARAM)&myObj); // Sends without any errors
...
afx_msg LRESULT MyApp::GetEvent(WPARAM wParam, LPARAM lParam)
{
myClass *zxc = new myClass();
zxc = lParam; // Something like this... but doesn't work
}
答案 0 :(得分:2)
只需在适当的位置转换指针:
<强>发件人:强>
pDlg->SendMessage(MyEvent, NULL, reinterpret_cast<LPARAM>(&myObj));
<强>接收器:强>
afx_msg LRESULT MyApp::GetEvent(WPARAM wParam, LPARAM lParam)
{
myClass * zxc = reinterpret_cast<myClass*>(lParam);
// ...
}