📄 9713.html
字号:
<html>
<head>
<title>Re: 如何在视窗标题上加上一个按钮呢??</title>
</head>
<body bgcolor="#FFFFFF" vlink="#808080">
<center>
<h1>Re: 如何在视窗标题上加上一个按钮呢??</h1>
</center>
<hr size=7 width=75%>
<hr size=7 width=75%><p>
Posted by <a href="mailto:winntuser@hotmail.com">Windows NT user</a> on January 31, 1999 at 21:42:38:<p>
In Reply to: <a href="9708.html">Re: 如何在视窗标题上加上一个按钮呢??</a> posted by Rong on January 31, 1999 at 14:58:13:<p>
: : : 如何在视窗标题上加上一个按钮呢??<br>: : 请参巧 "Visual Basic 6.0 与 Windows API 讲座"<br>: 我还是不会, 可否教一下呢??<p>在form:<br>Private Sub Command1_Click()<br> '<br>End Sub<p>Private Sub Form_Load()<br> prevWndProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)<br> SetWindowLong Me.hwnd, GWL_WNDPROC, AddressOf WndProc<br>End Sub<p>Private Sub Form_Unload(Cancel As Integer)<br> SetWindowLong Me.hwnd, GWL_WNDPROC, prevWndProc<br>End Sub<p>Function IsInImage(ByVal X As Integer, ByVal Y As Integer)<br> Dim r1 As RECT, r2 As RECT<br> Dim border As Integer<br> <br> IsInImage = False<br> GetWindowRect Me.hwnd, r1<br> GetClientRect Me.hwnd, r2<br> border = (r1.Right - r1.Left - r2.Right) / 2<br> <br> If X > r1.Left + border + Image1.Left And _<br> X < r1.Left + border + Image1.Left + Image1.Width And _<br> Y > r1.Top + border + Image1.Top And _<br> Y < r1.Top + border + Image1.Top + Image1.Height Then<br> <br> IsInImage = True<br> End If<br>End Function<br>在module:<br>Option Explicit<p>Public Const GWL_WNDPROC = (-4)<p>Public Const WM_NCHITTEST = &H84<br>Public Const HTCLIENT = 1<br>Public Const HTCAPTION = 2<p>Type RECT<br> Left As Long<br> Top As Long<br> Right As Long<br> Bottom As Long<br>End Type<p>Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long<br>Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long<p>Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long<br>Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long<br>Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long<p>Public prevWndProc As Long<p>Function WndProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long<br> WndProc = CallWindowProc(prevWndProc, hwnd, Msg, wParam, lParam)<br> <br> If Msg = WM_NCHITTEST And WndProc = HTCLIENT Then<br> If Form1.IsInImage(lParam Mod 65536, lParam \ 65536) Then<br> WndProc = HTCAPTION<br> End If<br> End If<br>End Function<br>注:<br>image1 用来代替form的标题列<br>form 的属性:<br> controlBox=false<br> ScaleMode=3<br>在image1上不止可以放commandButton,基本上,任何控制项都可以放上.
<br>
<br><hr size=7 width=75%><p>
<a name="followups">Follow Ups:</a><br>
<ul><!--insert: 9713-->
</ul><!--end: 9713-->
<br><hr size=7 width=75%><p>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -