vb中如何限制鼠标移动?急!!
vb中如何限制鼠标移动?急!!
推荐阅读
你自己看吧!
option explicitdeclare function clipcursor lib "user32" (lprect as any) as long
declare function clipcursorclear lib "user32" alias "clipcursor" (byval lprect as long) as long
declare function clienttoscreen lib "user32" (byval hwnd as long, lppoint as pointapi) as long
type rect
left as long
as long
right as long
bottom as long
end type
type pointapi
x as long
y as long
end type
public retvalue as long
public clipmode as boolean
public sub setcursor(clipobject as object, setting as boolean)
used to clip the cursor into the viewport and
turn off the default windows cursor
dim currentpoint as pointapi
dim cliprect as rect
if setting = false then
set clip state back to normal
retvalue = clipcursorclear(0)
exit sub
end if
set current position
with currentpoint
.x = 0
.y = 0
end with
find position on the screen (not the window)
retvalue = clienttoscreen(clipobject.hwnd, currentpoint)
designate clip area
with cliprect
. = currentpoint.y
.left = currentpoint.x
.right = .left + clipobject.scalewidth
.bottom = . + clipobject.scaleheight
end with clip it
retvalue = clipcursor(cliprect)
end sub


讨论区