首页
社区
课程
招聘
[求助]SendMessage 最后一个参数的奇怪用法
发表于: 2009-7-23 17:29 5307

[求助]SendMessage 最后一个参数的奇怪用法

2009-7-23 17:29
5307
以下代码是在本论坛找的.是一个扫雷的自动实现代码

但是不明白颜色标的部分 请大家讲解一下,非常感谢!

	for(int y=0;y<aa[1];y++)
	{
		for(int x=1;x<=aa[0];x++)
		{
			if(bb[x+(y*32)]==0x8f)
			{//右键
				::SendMessage((HWND__ *)(*wn),WM_RBUTTONDOWN,0,[COLOR="Red"](0x00400000+(y*0x00100000))|(0x0010*x));
				::SendMessage((HWND__ *)(*wn),WM_RBUTTONUP,0,[COLOR="red"](0x00400000+(y*0x00100000))|(0x0010*x));
			}
			else
			{//左键
				::SendMessage((HWND__ *)(*wn),WM_LBUTTONDOWN,0,[COLOR="red"](0x00400000+(y*0x00100000))|(0x0010*x));
				::SendMessage((HWND__ *)(*wn),WM_LBUTTONUP,0,[COLOR="red"](0x00400000+(y*0x00100000))|(0x0010*x));
			}
			
		}
  }


上面代码中LPARAM 参数为 0x4xxx+xx 是一个内存地址. 实在看不明白.请大家帮帮忙...


函数原型:
LRESULT SendMessage(
  HWND hWnd,      // handle to destination window
  UINT Msg,       // message
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
);


WM_RBUTTONDOWN
The WM_RBUTTONDOWN message is posted when the user presses the right mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse.

A window receives this message through its WindowProc function.

LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_RBUTTONDOWN
WPARAM wParam, // key indicators
LPARAM lParam // horizontal and vertical position
);
Parameters
wParam
Indicates whether various virtual keys are down. This parameter can be one or more of the following values. Value Description
MK_CONTROL The CTRL key is down.
MK_LBUTTON The left mouse button is down.
MK_MBUTTON The middle mouse button is down.
MK_RBUTTON The right mouse button is down.
MK_SHIFT The SHIFT key is down.
MK_XBUTTON1 Windows 2000/XP: The first X button is down.
MK_XBUTTON2 Windows 2000/XP: The second X button is down.


lParam
The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.



通常来说我们模拟鼠标是  ::SendMessage((HWND__ *)(*wn),WM_LBUTTONDOWN,0,坐标信息)

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (6)
雪    币: 206
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
看看 WM_RBUTTONDOWN 是怎么处理 lparam 的不就知道了
2009-7-23 17:35
0
雪    币: 179
活跃值: (26)
能力值: ( LV7,RANK:100 )
在线值:
发帖
回帖
粉丝
3
SendMessage中的wparam和lparam并没有固定的作用,或者说没有指定要传递的值是什么。要根据具体的情况来判断这两个参数中的值是什么意思。
如cutcut说的,你看看WM_RBUTTONDOWN的消息响应函数中是怎么处理lparam的。既然作者说是一个内存地址,那就是个内存地址。不能因为在鼠标消息中它表示的是一个坐标信息,就判定这里也应该是坐标信息。
重点不在传递的是什么东西,而是消息响应函数中是怎么利用和处理这个值的。
2009-7-23 17:48
0
雪    币: 4204
活跃值: (4183)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
处理的还是坐标值呀...

可是这么表示有什么特殊的意义呢?
2009-7-23 19:35
0
雪    币: 80
活跃值: (45)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
5
相对坐标的XY的十六进制,分放高位和低位。
2009-7-23 19:51
0
雪    币: 4204
活跃值: (4183)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
一语点通了...谢谢~~
2009-7-23 20:11
0
雪    币: 89
活跃值: (185)
能力值: ( LV9,RANK:270 )
在线值:
发帖
回帖
粉丝
7
楼主是外挂开发的吧。
2009-7-24 12:51
0
游客
登录 | 注册 方可回帖
返回
//