trapping mouse in picture box

gfreeman1
10-13-2000, 06:14 PM
How would i go about trapping the mouse inside the picture box that i am drawing a line in? I have absolutely no idea how to do this. If someone could give me some pointers i would really appreciate this.

BillSoo
10-13-2000, 06:32 PM
You can use the clipcursor API call. Here is a quick example:

<PRE><CODE>
'declared in a module
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Public Declare Sub ClipCursor Lib "user32" (lpRect As Any)
Public Declare Sub ClipCursorAll Lib "user32" Alias "ClipCursor" (ByVal n As Long)

Public Sub RestrictCursor(p as picturebox)
dim r as RECT

GetWindowRect p.hwnd, r
ClipCursor r
end sub

public sub ReleaseCursor()
ClipCursorAll 0
end sub
</PRE></CODE>

"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum