Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Private Type rect
sbleft As Long
sbtop As Long
sbright As Long
sbbottom As Long
End Type
Private Sub Command1_Click()
'定位鼠标
Dim x As Long, y As Long
Dim newrect As rect
x& = Screen.TwipsPerPixelX
y& = Screen.TwipsPerPixelY
With newrect
.sbleft = Form1.Left / x
.sbtop = Form1.Top / x
.sbright = .sbleft + Form1.Width / x
.sbbottom = .sbtop + Form1.Height / x
End With
ClipCursor newrect
End Sub