如何获得Form的caption上的doubleclick事件??(50分)

  • 主题发起人 主题发起人 nuke
  • 开始时间 开始时间
N

nuke

Unregistered / Unconfirmed
GUEST, unregistred user!
做了一个Dockwindow,想要作出如果在caption上双击
就切换Dock状态的效果来。
默认的似乎双击form caption就是最大化窗口。
如何做呢?
 
WM_NCLBUTTONDBLCLK
当用户用鼠标左键双击非客户区域时发出此消息。
WM_NCLBUTTONDBLCLK
nHittest = (INT) wParam;
// hit-test value
pts = MAKEPOINTS(lParam);
// position of cursor

Parameters
nHittest
Value of wParam. Specifies the hit-test value returned by the DefWindowProc function as a result of processing the WM_NCHITTEST message. For a list of hit-test values, see WM_NCHITTEST.
其中:nHittest = HTCAPTION 表示在标题栏
pts
Value of lParam. Specifies aPOINTS structure that contains the x- and y-coordinates of the cursor. The coordinates are relative to the upper-left corner of the screen.
Return Values
If an application processes this message, it should return zero.
 
重载WM_NCLBUTTONDBLCLK事件,以下是一个例子:
procedure WMNCLBUTTONDBLCLK(var msg :TWMNCLBUTTONDBLCLK);message WM_NCLBUTTONDBLCLK;
procedure TForm1.WMNCLBUTTONDBLCLK(var msg :TWMNCLBUTTONDBLCLK);
begin
if msg.HitTest = HTCAPTION then
//你自己的处理方法!
Label1.Caption := 'Double click the caption !'
else
inherited;
end;
 
Tqz说出了原理,
柳五写出了方法 , 你看着办吧?
TForm1 = class(TForm)
Label1: TLabel;
private
{ Private declarations }
public
{ Public declarations }
procedure WMNCLBUTTONDBLCLK(var msg :TWMNCLBUTTONDBLCLK);message WM_NCLBUTTONDBLCLK;
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.WMNCLBUTTONDBLCLK(var msg :TWMNCLBUTTONDBLCLK);
begin
if msg.HitTest = HTCAPTION then
//你自己的处理方法!
Label1.Caption := 'Double click the caption !'
else
inherited;
end;
end.
 
多人接受答案了。
 
后退
顶部