当前位置:主页   - 电脑 - 程序设计 - Delphi
在delphi中如何限制鼠标的移动区域。
来源:网络转载   作者:未知   更新时间:2008-12-23
收藏此页】    【字号    】    【打印】    【关闭
下面把鼠标的移动区域限制在(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.

其它资源
来源声明

版权与免责声明
1、本站所发布的文章仅供技术交流参考,本站不主张将其做为决策的依据,浏览者可自愿选择采信与否,本站不对因采信这些信息所产生的任何问题负责。
2、本站部分文章来源于网络,其版权为原权利人所有。由于来源之故,有的文章未能获得作者姓名,署“未知”或“佚名”。对于这些文章,有知悉作者姓名的请告知本站,以便及时署名。如果作者要求删除,我们将予以删除。除此之外本站不再承担其它责任。
3、本站部分文章来源于本站原创,本站拥有所有权利。
4、如对本站发布的信息有异议,请联系我们,经本站确认后,将在三个工作日内做出修改或删除处理。
请参阅权责声明