Parsi Coders
زندانی کردن موس داخل فرم - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Software Development Programming (http://parsicoders.com/forumdisplay.php?fid=37)
+--- انجمن: Visual Basic Programming (http://parsicoders.com/forumdisplay.php?fid=39)
+---- انجمن: Visual Basic 6 (http://parsicoders.com/forumdisplay.php?fid=44)
+---- موضوع: زندانی کردن موس داخل فرم (/showthread.php?tid=855)



زندانی کردن موس داخل فرم - Ghoghnus - 09-04-2011

سلام دوستان
با این سورس میتونید موس را روی فرمتون زندانی کنید!
کد:
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