Parsi Coders

نسخه‌ی کامل: زندانی کردن موس داخل فرم
شما در حال مشاهده نسخه آرشیو هستید. برای مشاهده نسخه کامل کلیک کنید.
سلام دوستان
با این سورس میتونید موس را روی فرمتون زندانی کنید!
کد:
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 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 POINT)
Private Declare Sub OffsetRect Lib "user32" (lpRect As RECT, ByVal X As Long, ByVal Y As Long)


Private Sub Command1_Click()
End
End Sub

Private Sub Form_Load()
On Error Resume Next



Dim client As RECT
Dim upperleft As POINT
Dim lHwnd As Long
On Error Resume Next
lHwnd = Me.hWnd
If lHwnd = 0 Then Exit Sub
GetClientRect Me.hWnd, client
upperleft.X = client.left
upperleft.Y = client.top
ClientToScreen Me.hWnd, upperleft
OffsetRect client, upperleft.X, upperleft.Y
ClipCursor client
Show

End Sub