Created
March 24, 2018 07:34
-
-
Save wjx0912/c2aff6fd2419d68f4ce3462a6737bb10 to your computer and use it in GitHub Desktop.
c++ message object management 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// send | |
SendingMethod::SendMsgId( ... ) | |
{ | |
... | |
std::unique_ptr<MyParams> myParams( new MyParams(value1, value2, value3) ); | |
if (PostThreadMessage(MSG_ID, 0, reinterpret_cast<LPARAM>(myParams.release())) { | |
myParams.release(); // is postmessage failed | |
} | |
... | |
} | |
// receive | |
ReceivingMethod::OnMsgId( WPARAM wParam, LPARAM lParam) | |
{ | |
std::unique_ptr<MyParams> myParams( reinterpret_cast<MyParams*>(lParam) ); | |
... // use object | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment