VB中API问题
Form1中有两个按钮,按下一个按钮后,鼠标只能在窗体上移动,按下另一个按钮,鼠标只能在按钮上移动
Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
privateType RECT
left As Long
top As Long
right As ong
bottom As Long
End Type
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub confineto(myctl As Object)
On Error Resume Next 这句什么意思啊?
Dim temprect As RECT 这两个定义什么意思
Dim pt As POINTAPI
With myctl
If TypeOf myctl Is Screen Then
tmprect.left = 0
tmprect.top = 0
tmprect.right = (.Width \ Screen.TwipsPerPixelX)
tmprect.bottom = (.Height \ Screen.TwipsPerPixelY)
ElseIf TypeOf myctl Is Form Then
tmprect.left = (.left \ Screen.TwipsPerPixelX)
tmprect.top = (.top \ Screen.TwipsPerPixelY)
tmprect.right = (.left + .Width) \ Screen.TwipsPerPixelX
tmprect.bottom = (.top + .Height) \ Screen.TwipsPerPixelY
(.Width \ Screen.TwipsPerPixelX)什么意思?
Else
pt.x = 0
pt.y = 0
Call ClientToScreen(.hwnd, pt) 什么来的?
tmprect.left = pt.x
tmprect.top = pt.y
pt.x = .Width \ Screen.TwipsPerPixelX
pt.y = .Height \ Screen.TwipsPerPixelY
Call ClientToScreen(.hwnd, pt)
tmprect.right = pt.x
tmprect.bottom = pt.y
End If
Call ClipCursor
End With
End Sub
Private Sub CmdButton_Click()
Static cliped As Boolean 用Boolean有什么用?
If Not cliped Then
confineto CmdButton
cliped = True
Else
confineto Screen
cliped = False
End If
End Sub
Private Sub CmdForm_Click()
Static cliped As Boolean
If Not cliped Then
confineto Form1
cliped = True
Else
confineto Screen
cliped = False
End If
End Sub
我有点看不懂,哪位高手教教我