无忧岛

01 十一, 2008

用API实现锁定鼠标 – VB

Posted by: kinglife In: VB

只需要在窗体上画两个按钮分别叫 command1和command2 然后输入下面代就可以拉 :dm/cy


Option Explicit
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long

Private Sub Command1_Click() '锁定鼠标
Dim r As RECT
r.Left = 200: r.Top = 200   '锁定鼠标移动区域
r.Right = 200: r.Bottom = 200
ClipCursor r
End Sub

Private Sub Command2_Click() '解除锁定
ClipCursor ByVal 0&
End Sub

点了锁定了之后,鼠标不能移动到解除按钮上可别慌噢:dm/tx,记得用键盘的tab键盘或者方向键移动下就是啦:dm/tx
恶作剧推荐指数 ★★★★☆ 哈哈 :dm/cy :dm/hq 睡觉咯

版权所有,转载时必须以链接形式注明作者和原始出处及本声明:KingLife@无忧岛

本文链接: http://www.islandcn.com/post/340.html


Tags: , ,

No Responses to "用API实现锁定鼠标 – VB"

Comment Form

Categories

Flickr PhotoStream

    flickrRSS probably needs to be setup

About

Name:KingLife
Email:lifewz#163.com