导航

锁定鼠标在窗体中(vb6)

Posted on 2007-03-22 16:05  pegger  阅读(555)  评论(1编辑  收藏  举报
Private Declare Sub ClipCursor Lib "user32" (lpRect As RECT)
Private Declare Sub GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT)
Private Declare Sub ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINT)
Private Declare Sub OffsetRect Lib "user32" (lpRect As RECT, ByVal x As LongByVal y As Long)
Private Declare Function ClipCursorBynum& Lib "user32" Alias "ClipCursor" (ByVal lpRect As Long)

Private Type POINT
    x 
As Long
    y 
As Long
End Type

Private Type RECT
    
left As Long
    top 
As Long
    
right As Long
    bottom 
As Long
End Type

'锁鼠标
Public Sub LockMouse()
    
Dim client As RECT
    
Dim upperleft As POINT
    GetClientRect 
Me.hwnd, client
    upperleft.x 
= client.left
    upperleft.y 
= client.top
    ClientToScreen 
Me.hwnd, upperleft
    OffsetRect client, upperleft.x, upperleft.y
    ClipCursor client
End Sub


'解鼠标
Public Sub UpMouse()
    ClipCursorBynum
& 0
End Sub


河南恒友科贸有限公司 
电话 :0371-53733453    传真:0371-65388972
地址:郑州市郑花路8号 E-mail:hengyousoft@QQ.com