7341.html
来自「VB技巧问答10000例,是一个教程」· HTML 代码 · 共 27 行
HTML
27 行
<html>
<head>
<title>Re: Re; Splash Window</title>
</head>
<body bgcolor="#FFFFFF" vlink="#808080">
<center>
<h1>Re: Re; Splash Window</h1>
</center>
<hr size=7 width=75%>
<hr size=7 width=75%><p>
Posted by <a href="mailto:honey0@tcts1.seed.net.tw">Honey</a> on November 14, 1998 at 12:57:43:<p>
In Reply to: <a href="7338.html">Re; Splash Window</a> posted by David Wong on November 14, 1998 at 10:59:20:<p>
可以使用API使滑鼠游标局限于表单中<br>宣告方式如下<br>Private Declare Function ClientToScreen Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long<br>Private Declare Function ClipCursor Lib "user32" (lpRect As RECT) As Long<br>若于模组中使用 得去掉Private<p>另外还得宣告一些型态<br>Private Type POINTAPI<br> X As Long<br> Y As Long<br>End Type<p>Private Type RECT<br> Left As Long<br> Top As Long<br> Right As Long<br> Bottom As Long<br>End Type<br>若于模组中使用 也得去掉Private<p>之后提供你一个SUB<br>Public Sub ClipTo(ToCtl As Object)<p>On Error Resume Next<p>Dim tmpRect As RECT<br>Dim pt As POINTAPI<p>With ToCtl<p> If TypeOf ToCtl Is Form Then<br> tmpRect.Left = (.Left \ Screen.TwipsPerPixelX)<br> tmpRect.Top = (.Top \ Screen.TwipsPerPixelY)<br> tmpRect.Right = (.Left + .Width) \ Screen.TwipsPerPixelX<br> tmpRect.Bottom = (.Top + .Height) \ Screen.TwipsPerPixelY<br> ElseIf TypeOf ToCtl Is Screen Then<br> tmpRect.Left = 0<br> tmpRect.Top = 0<br> tmpRect.Right = (.Width \ Screen.TwipsPerPixelX)<br> tmpRect.Bottom = (.Height \ Screen.TwipsPerPixelY)<br> Else<br> pt.X = 0<br> pt.Y = 0<br> Call ClientToScreen(.hWnd, pt)<br> tmpRect.Left = pt.X<br> tmpRect.Top = pt.Y<br> pt.X = .Width<br> pt.Y = .Height<br> Call ClientToScreen(.hWnd, pt)<br> tmpRect.Bottom = pt.Y<br> tmpRect.Right = pt.X<br> End If<br> <br> Call ClipCursor(tmpRect)<p>End With<p>End Sub<p>之后 只要在FORM_LOAD() 中加入以下程式码<br>ClipTo Me<br>Me.Moveable = False<br>就可以限制滑鼠游标<br>另外 可别忘了在Form_Unload( ...)中加入<br>ClipTo Screen<br>否则 程式结束时 滑鼠还是会局限在那个范围喔<p>另外 如果表单移动过后 滑鼠便不受局限<br>所以我用Me.Moveable = False<br>使得表单不能移动<br>若你想让表单可移动 可去掉Me.Moveable = False<br>另外在Form_MouseMove()<br>加入ClipTo Me<br>若你不想将程序放入message window<br>也可以稍作修改 将Me改成message window的NAME<br>
<br>
<br><hr size=7 width=75%><p>
<a name="followups">Follow Ups:</a><br>
<ul><!--insert: 7341-->
<!--top: 7426--><li><a href="7426.html">Re; 十分好的方法</a> <b>David Wong</b> <i>22:26:33 11/17/98</i>
(<!--responses: 7426-->0)
<ul><!--insert: 7426-->
</ul><!--end: 7426-->
</ul><!--end: 7341-->
<br><hr size=7 width=75%><p>
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?