关于B00LPostMessage

kittymimihh 2009-05-30 09:01:41
B00L PostMessage(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam);
想知道后面两个参数的用法,能用之传递什么参数?比如说数组?能传递吗?
...全文
80 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
pathuang68 2009-05-30
  • 打赏
  • 举报
回复
什么都可以传递!下面是我在http://topic.csdn.net/u/20090510/22/bdd28333-7dce-4139-94be-4d17bedb31c7.html帖子中的回帖内容:

Upon your request of "欢迎提供英文文章" :).

Please check up this hyperlink:
http://bbs.zdnet.com.cn/thread-578222-1-1.html

basically, WPARAM and LPARAM is int and long respectively, and on Win32 platform, sizeof(int) = sizeof(long) = 4bytes, that means WPARAM or LPARAM can be cast to a pointer(on Win32 platform, a pointer is an 32-bit number), so you can use WPARAM or LPARAM to transfer almost any kind of information, for example(in MFC):


CPoint a(89, 90);
SomeViewPointer->PostMessage(MESSAGE_ID, (WPARAM)&a, (LPARAM)"Hello, world");


and then

LRESULT SomeView::MESSAGE_ID_HANDLER(WPARAM wParam, LPARAM lParam)
{
...
TRACE("Coordination:(%d, %d), and the message is: %s\n", ((CPoint*)wParam)->x, ((CPoint*)wParam)->y, lParam);
...
}

will print:
Coordination:(89, 89), and the message is: Hello, world

Hope this would be a little bit of help. :)
Sou2012 2009-05-30
  • 打赏
  • 举报
回复
up!!!

65,210

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧