如何限制鼠标移动范围

g3hkm 2001-08-04 08:34:18
用mapwindowpoints限制后,只要移动窗体就能破解
要如何才能继续限制?
...全文
372 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
xzm2000 2001-08-06
  • 打赏
  • 举报
回复
wm_move是窗体在移动完成后产生的一个消息,所以你每次移动窗体后马上重新clipcurrsor就可以了
xzm2000 2001-08-06
  • 打赏
  • 举报
回复
写一个接受消息的过程
procedure WmMove(var M: TMsg);message WM_MOVE;

procedure TForm1.WmMove(Var M: TMsg);
begin
inheritd;
showmessage('move');
end;
g3hkm 2001-08-06
  • 打赏
  • 举报
回复
怎么触发wm_move了?
jackylee 2001-08-06
  • 打赏
  • 举报
回复
gz
qzg 2001-08-05
  • 打赏
  • 举报
回复
下面把鼠标的移动区域限制在(100,100,200,200)

var rect:trect;
begin
rect.left:=100;
rect.top:=100;
rect.bottom:=200;
rect.right:=200;
windows.clipcursor(@rect);



下面恢复鼠标的移动区域
windows.clipcursor(0);

具体的列子就不用举了吧,很简单的。嘻嘻嘻嘻嘻

在delphi中的帮助是这么写的:

the clipcursor function confines the cursor to a rectangular area on the screen.
if a subsequent cursor position (set by the setcursorpos function or the mouse)
lies outside the rectangle, windows automatically adjusts the position to keep the
cursor inside the rectangular area.

bool clipcursor(

const rect *lprect // pointer to structure with rectangle
);


parameters

lprc

points to the rect structure that contains the screen coordinates of the upper-
left and lower-right corners of the confining rectangle. if this parameter is
null, the cursor is free to move anywhere on the screen.



return values

if the function succeeds, the return value is nonzero.
if the function fails, the return value is zero. to get extended error information, call getlasterror.

remarks

the cursor is a shared resource. if an application confines the cursor, it must
release the cursor by using clipcursor before relinquishing control to another
application.
the calling process must have winsta_writeattributes access to the window station.
xzm2000 2001-08-04
  • 打赏
  • 举报
回复
你试试在接到wm_move消息后马上再用clipcursor限制,应该可以的
sundayboys 2001-08-04
  • 打赏
  • 举报
回复
如果不行的话,试试GetcursorPos、SetCursorPos啊
chenjun631 2001-08-04
  • 打赏
  • 举报
回复
取鼠标坐标,加以限制
g3hkm 2001-08-04
  • 打赏
  • 举报
回复
就是用clipcursor限制后,移动窗体一下就破解的
sundayboys 2001-08-04
  • 打赏
  • 举报
回复
参见http://www.csdn.net/expert/topic/219/219458.shtm
sundayboys 2001-08-04
  • 打赏
  • 举报
回复
ClipCursor搞定!!!

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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