2013-05-13 97 views
1

我可以使用對象發送消息嗎? 喜歡的東西:MFC發送消息中的對象

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 
} 
+1

myClass的* zxc =(myClass)lParam; – 2013-05-13 19:38:29

+0

非常感謝您的幫助!它工作得很好 – FireForce 2013-05-13 19:39:45

回答

2

只投的指針有和回酌情:

發件人:

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

接收機:

afx_msg LRESULT MyApp::GetEvent(WPARAM wParam, LPARAM lParam) 
{ 
    myClass * zxc = reinterpret_cast<myClass*>(lParam); 
    // ... 
}