?? documents2.htm
字號:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<style><!--
body,table {font-family:"宋體"; font-size: 9pt; line-height:11pt;}
a {text-decoration:none} a:hover {color:red;text-decoration:underline}
--></style>
<title>使窗口總在最前</title>
</head>
<body link="#FF0000" vlink="#FF0000" alink="#FF0000" bgcolor="#FFC8C8">
<table border="0" width="100%" cellspacing="4" cellpadding="6">
<tr>
<td width="100%" bgcolor="#336699"><font color="#FFFFFF">使窗口總在最前</font></td>
</tr>
</table>
<p> 曾看到一個問題:如何使我的窗口總在最前?使用api函數
SetWindowPos 可以很容易的作到。</p>
<p> 顧名思義, SetWindowPos
就是完成設置窗口位置和狀態(pos=position)的功能。源代碼如下:</p>
<p><font color="#000080"> Option Explicit<br>
</font><br>
<font color="#000080">Private Declare Function</font> SetWindowPos <font
color="#000080">Lib</font> "user32" (<font color="#000080">ByVal</font> hwnd <font
color="#000080">As Long</font>, <font color="#000080">ByVal</font> hWndInsertAfter <font
color="#000080">As Long</font>, <font color="#000080">ByVal</font> x <font color="#000080">As
Long</font>, <font color="#000080">ByVal</font> y <font color="#000080">As Long</font>, <font
color="#000080">ByVal</font> cx <font color="#000080">As Long</font>, <font
color="#000080">ByVal</font> cy <font color="#000080">As Long</font>, <font
color="#000080">ByVal</font> wFlags <font color="#000080">As Long</font>) <font
color="#000080">As Long</font><br>
<br>
<font color="#000080">Private Const</font> HWND_TOPMOST& = -1<br>
<font color="#008000"> '
將窗口置于列表頂部,并位于任何最頂部窗口的前面<br>
</font> <font color="#000080">Private Const</font> SWP_NOSIZE& =
&H1<br>
<font color="#008000"> ' 保持窗口大小<br>
</font> <font color="#000080">Private Const</font> SWP_NOMOVE& =
&H2<br>
<font color="#008000"> ' 保持窗口位置<br>
</font><br>
<font color="#000080">Private Sub</font> Form_Load()<br>
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE <font color="#000080">Or</font> SWP_NOSIZE<br>
<font color="#008000"> '
將窗口設為總在最前<br>
</font><font color="#000080"> End Sub</font></p>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -