كود حصر الفأرة داخل نطاق معين

0
ضع الكود في الفورم



Private Declare Sub ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINT)
Private Declare Sub ClipCursor Lib "user32" (lpRect As Any)
Private Declare Sub OffsetRect Lib "user32" (lpRect As RECT, ByVal X As Long, ByVal Y As Long)
Private Declare Sub GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT)
Private Type RECT
Left As Integer
Top As Integer
Right As Integer
Bottom As Integer
End Type
Private Type POINT
X As Long
Y As Long
End Type



هذا الأمر يحصر الفأرة داخل الفورم
Private Sub Command1_Click() 
Dim Client As RECT
Dim Up As POINT
ClientToScreen Me.hwnd, Up
GetClientRect Me.hwnd, Client
OffsetRect Client, Up.X, Up.Y
Up.X = Client.Left
Up.Y = Client.Top
ClipCursor Client
End Sub


هذا الأمر بحرر الفأرة
Private Sub Command2_Click()
ClipCursor ByVal 0&
End Sub

يمكنك حصر الفأرة في اي اداة تريدها فقط قم باستبدال Me.hwnd

  text1.hwnd   , label1.hwnd

جميع الحقوق محفوظه © Visual Basic 6 MAN