怎样使用PostMessage把一个Struct传给一个窗体?
解决方案 »
- 如何避免使用TerminateThread()?
- 如何让一个windows程序暂停?
- 跪求高人指点串口高速通信问题,请高手多指教!!!!
- windows2000 server服务器+SQL Server2000 服务起重起,网络用户不能马上登陆
- 请教一个LineTo的问题
- vc在哪里指定目录?
- 在对话框里,如何避免按下Enter或者Ecs键时,对话框会关闭的情况?
- socket的问题。。。!
- 如何加入SystemTray.h SystemTray.cpp CCDEAudio.cpp etc
- CString Format问题
- 关于连接数据库大不开的现象,哪位帮我看下?谢谢 !
- 请问CEdit类创建的文本框怎样才能和普通的文本框一样``有3D感`?
struct {...} ST;1.发送:ST * p = new ST;
p->.. = ;
p->.. = ;
PostMessage(hwindow, message1, (WPARAM)p, LPARAM lparam);2.接受
//在你的窗口LONG onMessage1(WPARAM wparam, LPARAM lparam)
{
ST * p = (ST*) wparam;
if (0 == p)
{
//process error here
}
else
{
p->.. 取数据
处理
}
return 1L;
}
UINT message,
WPARAM wParam = 0,
LPARAM lParam = 0 );
接受端拿到这个地址访问的是错误的数据。
见 MSDN
WM_COPYDATARes
An application must use theSendMessage function to send this message, not thePostMessage function. 应该是SendMessage发送copydata消息The data being passed must not contain pointers or other references to objects not accessible to the application receiving the data. While this message is being sent, the referenced data must not be changed by another thread of the sending process. The receiving application should consider the data read-only. The pcds parameter is valid only during the processing of the message. The receiving application should not free the memory referenced by pcds. If the receiving application must access the data after SendMessage returns, it must copy the data into a local buffer. 且接受侧肯定不能删除消息内容;它是复制消息内容的