把Form的Moveable设为False,Borderstyle设为1.代码如下。==========亩喊===========Option ExplicitDim R As RECTPrivate Type RECT Left As Long Top As Long Right As Long Bottom As LongEnd TypePrivate Declare Function ClipCursor Lib "user32" (lpRect As RECT) As Long'lpRect-鼠标穗顷光标限制到的矩形Private Declare Function ClipCursorByNum Lib "user32" Alias "ClipCursor" (lpRect As Long) As Long'lpRect-传0,取消鼠标光猜耐陆标限制Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As LongPrivate Sub Form_Load() '窗体载入后,鼠标只能在窗体范围内移动SetRect R, Left / Screen.TwipsPerPixelX + 3, Top / Screen.TwipsPerPixelY + 3, (Left + Width) / Screen.TwipsPerPixelX - 3, (Top + Height) / Screen.TwipsPerPixelY - 3ClipCursor REnd SubPrivate Sub Form_Unload(Cancel As Integer) '窗体退出时,取消鼠标光标限制范围ClipCursorByNum 0End Sub
相关文章
-
鼠标失灵怎么办?
2023-04-10 12:15 阅读(575) -
鼠标灵敏度怎么调?
2023-04-04 13:03 阅读(598) -
鼠标点一下变两下怎么办
2023-03-31 17:23 阅读(671)