关于标题栏?(50分)

  • 主题发起人 主题发起人 bbcse
  • 开始时间 开始时间
B

bbcse

Unregistered / Unconfirmed
GUEST, unregistred user!
1。如何捕获鼠标双击了标题栏?<br>2。如何控制最大化按钮的状态(让它显示为还原状态)?
 
你可以试着截获WM_NCLBUTTONDBLCLK消息来捕获鼠标双击标题栏<br><br>WM_NCLBUTTONDBLCLK &nbsp;<br>nHittest = (INT) wParam; &nbsp; &nbsp;// hit-test value <br>pts = MAKEPOINTS(lParam); &nbsp; // position of cursor <br><br>nHittest的值如果是HTCAPTION那就是鼠标双击了标题栏<br><br>你可以查一下WinAPI帮助文档中关于WM_NCLBUTTONDBLCLK和WM_NCHITTEST这<br>两个消息的解释。<br>
 
&gt;&gt;&gt;&gt;
 
晚上刚好有空,试了一下截获标题栏双击事件,代码如下:<br><br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; &nbsp; procedure WMNCLButtonDblClick(var Message: TWMNCLBUTTONDBLCLK);<br>&nbsp; &nbsp; &nbsp; message WM_NCLBUTTONDBLCLK;<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>{ TForm1 }<br><br>procedure TForm1.WMNCLButtonDblClick(var Message: TWMNCLBUTTONDBLCLK);<br>begin<br>&nbsp; if Message.HitTest = HTCAPTION then<br>&nbsp; begin<br>&nbsp; &nbsp; // ShowMessage('Double Click');<br>&nbsp; &nbsp; ...<br>&nbsp; end<br>&nbsp; else inherited;<br>end;<br><br>end.<br>
 
接受答案了.
 
后退
顶部