请问如何判断鼠标所处位置?移到该位置时可以触发事件?(20分)

  • 主题发起人 主题发起人 foxgirl
  • 开始时间 开始时间
F

foxgirl

Unregistered / Unconfirmed
GUEST, unregistred user!
在屏幕上的位置,不管当前屏幕上是桌面还是应用程序窗口,都能响应事件?
 
WinAPI的GetCursorPos可以取得鼠标的位置:
...
var
pos : POINT;
begin
GetCursorPos(pos);
end;
 
procedure TForm1.Timer1Timer(Sender: TObject);//用个Timer控件来捕
var
CursorPt: TPoint;
begin
GetCursorPos(CursorPt);
if CursorPt.X = ??? and CursorPt.Y = ??? then
......
end;
 
谢楼上两位朋友,我想把鼠标移到屏幕最底一行:
if CursorPt.Y = screen.height then
......

可运行时把鼠标移到屏幕最底一行时,却并不能响应事件,不知要怎么样才行?
 
屏幕最底一行鼠标很难到,可以让screen.height-n触发
 
To foxgirl:
你那样精确到一个点, 当然难触发了, 可写成:
if CursorPt.Y > (screen.height - 10) then

并且Timer的时间间隔调小一些, 如100

 
搞定了,送分
 

Similar threads

回复
0
查看
830
不得闲
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部