请问怎样向程序发送模拟鼠标移动消息,如: WM_RBUTTONDOWN://鼠标右键被按下 WM_LBUTTONDOWN://鼠标左键被按下 WM_LBUTTONUP://释放鼠标左键 WM_RBUTTONUP://释放鼠标右键 WM_LBUTTONDBLCLK://鼠标左键双击 WM_RBUTTONDBLCLK://鼠标右键双击移动呢?!??
解决方案 »
- 在没有安装Delphi6的机器上如何设置ODBC连接Delphi6自己的数据库(*.db)
- 急聘delphi程序员(深圳)
- 最小化后如果有提示框,怎样把提示框显示在屏幕前面?
- 请问数据库导航控件(TDBNavigator) 只有图标,怎样才能加上文字标签说明?谢谢
- 求学习方法及指导书籍。。。。
- delphi6.0--installshild 做安装文件时 安装后在windows内的新增,册除内看到的程序名是default,该在哪理改自已想要的名呢?
- 初学Delphi....头痛!!!!谁进来帮帮帮我....
- 初学者问题(如果把listview的viewstyle=vsreport时,怎样定位第n行,第n列?有什么?
- 关于Image控件不能随着相片尺寸变化的问题
- 急事!!!请教!!!
- [求助]关于AdoQuery的Filter属性的问题
- 有一小问题_我打开别人的源码时,在设计时看不到主窗体?
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
Parameters
fwKeys
Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
MK_CONTROL Set if the CTRL key is down.
MK_LBUTTON Set if the left mouse button is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the SHIFT key is down.看看wParam的描述
不是很明白 以上是不是拉住右键移动?!?
The WM_LBUTTONDOWN message is posted when the user presses the left 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. WM_LBUTTONDOWN
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
Parameters
fwKeys
Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
MK_CONTROL Set if the ctrl key is down.
MK_LBUTTON Set if the left mouse button is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the shift key is down.
xPos
Value of the low-order word of lParam. Specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
yPos
Value of the high-order word of lParam. Specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area. 从上面可以看到 wParam 是鼠标键的按键信息, lParam是鼠标键按下时的坐标。其中lParam的高位是Y,低位是X
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
rect:TRect;
x,y,lPara:Integer;
begin
GetWindowRect(Self.Handle,rect);//获得当前窗口的位置
x:=rect.Left+10; //当前窗口左上角x坐标加10
y:=rect.Top+10; //当前窗口左上角y坐标加10
lPara:=x+(y shl 16); //就算出lParam的值//向当前窗口发送左键按下消息,相当于鼠标在相对窗口(10,10)的位置按下
PostMessage(Self.Handle,WM_LBUTTONDOWN,MK_LBUTTON,lpara);end;//相应鼠标按下事件
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
showmessage('WM_lbuttondown 在 ' + IntToStr(X) + ','+ IntToStr(y));
end;end.