vb中如何限制鼠标移动?急!!
vb中如何限制鼠标移动?急!!
楼主capnet(金山)2003-08-05 22:54:55 在 VB / 基础类 提问vb中如何限制鼠标移动?急!! 问题点数:100、回复次数:3Top
1 楼jacobran()回复于 2003-08-05 22:59:55 得分 100
你自己看吧!
Option ExplicitDeclare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Declare Function ClipCursorClear Lib "user32" Alias "ClipCursor" (ByVal lpRect As Long) As Long
Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Type POINTAPI
X As Long
Y As Long
End Type
Public RetValue As Long
Public ClipMode As Boolean
Public Sub SetCursor(ClipObject As Object, Setting As Boolean)
" used to clip the cursor into the viewport and
" turn off the default windows cursor
Dim CurrentPoint As POINTAPI
Dim ClipRect As RECT
If Setting = False Then
" set clip state back to normal
RetValue = ClipCursorClear(0)
Exit Sub
End If
" set current position
With CurrentPoint
.X = 0
.Y = 0
End With
" find position on the screen (not the window)
RetValue = ClientToScreen(ClipObject.hwnd, CurrentPoint)
" designate clip area
With ClipRect
.Top = CurrentPoint.Y
.Left = CurrentPoint.X
.Right = .Left + ClipObject.ScaleWidth
.Bottom = .Top + ClipObject.ScaleHeight
End With " clip it
RetValue = ClipCursor(ClipRect)
End Sub
Top
2 楼capnet(金山)回复于 2003-08-05 23:02:52 得分 0
好了,多谢了。Top
3 楼diyee(锦衣夜行)回复于 2003-08-05 23:23:22 得分 0
Option Explicit
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Private Sub Command1_Click()
Dim r As RECT
r.Left = 0: r.Top = 0
r.Right = 320: r.Bottom = 200
ClipCursor
End Sub
Private Sub Command2_Click()
ClipCursor ByVal 0&
End Sub
Top
-
相关文章
2秒记住本站域名
玩过泡泡龙吗?Readygo?Go! 再加上.Com.Cn的后缀,那就是大名小顶的readygo.com.cn
