用VB如何运行窗体问题
用VB如何运行窗体时,鼠标只在窗体上活动,不能到电脑桌面上,如何作?
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