(MSDN中的remark)If you send a message in the range below WM_USER to the asynchronous message functions (PostMessage, SendNotifyMessage, and SendMessageCallback), its message parameters can not include pointers. Otherwise, the operation will fail. The functions will return before the receiving thread has had a chance to process the message and the sender will free the memory before it is used。
自己在程序中使用了一個postmessage向父窗口發送自定義消息,帶一個指針參數,結果在父窗口的函數中取出參數之後發現內容被改動了!O.M.G.!調了一上午,能想到的地方都測試了,還是出錯,忽然想到前兩天也使用自定義消息傳遞過指針爲什麼那一次就行呢?找出程序來檢查了一遍,發現那個使用的是sendmessage,也就是發送同步消息,疑問:除了一個放入消息隊列,直接返回(post),一個等待知道處理完成返回(send)外,還有什麼區別?查了一個MSDN發現,還真不是那麼簡單的一回事,又到網上一搜,發現原來如此,把post改爲send之後果然,指針參數就正常了。