6 Январь 2009

Как ограничить передвижения курсора?

Мышь |  Таги: , ,

Как ограничить передвижения курсора?

Option Explicit

Private Declare Sub ClipCursor Lib "user32" (lpRect As Any)
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 POINTAPI)
Private Declare Sub OffsetRect Lib "user32" _
            (lpRect As RECT, ByVal x As Long, ByVal y As Long)
Private Type RECT
left As Integer
top As Integer
right As Integer
bottom As Integer
End Type
Private Type POINTAPI
x As Long
y As Long
End Type

Private Sub Form_Load()
Command1.Caption = "Ограничить передвижение!"
Command2.Caption = "Снять ограничение!"
End Sub

Private Sub Form_Unload(Cancel As Integer)
ClipCursor ByVal 0&
End Sub

Private Sub Command1_Click()
Dim client As RECT
Dim upperleft As POINTAPI
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

Private Sub Command2_Click()
ClipCursor ByVal 0&
End Sub


Оставить комментарий

Я не робот.


типография москва и типография полиграфия .