1

我可以发送带有对象的消息吗?就像是:

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
}
4

1 回答 1

2

只需在适当的地方来回投射指针:

发件人:

pDlg->SendMessage(MyEvent, NULL, reinterpret_cast<LPARAM>(&myObj));

接收者:

afx_msg LRESULT MyApp::GetEvent(WPARAM wParam, LPARAM lParam)
{
    myClass * zxc = reinterpret_cast<myClass*>(lParam);
    // ...
}
于 2013-05-13T19:42:13.137 回答