如何判断mouse按下了最小化按钮

I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
方法一:截获 WM_SYSCOMMAND消息,看窗体是否处于最小化状态
type
TForm1 = class(TForm)
private
procedure WMSysCommand(var Message: TMessage); message WM_SYSCOMM
AND;
//...
end;
implementation
{$R *.DFM}
procedure TForm1.WMSysCommand(var Message:TMessage);
begin
if Message.WParam = SC_ICON then //最小化了
begin
//form1.hide; ...
end
else
inherited;
end;
方法二,直接判断是否点了窗体非客户区的最小化按钮
type
TForm1 = class(TForm)
private
procedure Minimize(var mess:TWMNCLBUTTONDOWN);message WM_NCLBUTTON
DOWN;
//...
end;
implementation
{$R *.DFM}
procedure TForm1.Minimize(var mess:TWMNCLBUTTONDOWN);
begin
if mess.hittest=htreduce then //htreduce表示是否按了最小化按钮
begin
//Form1.hide; ...
end
else
inherited;
end;
 

Similar threads

I
回复
0
查看
214
import
I
I
回复
0
查看
225
import
I
I
回复
0
查看
250
import
I
I
回复
0
查看
230
import
I
顶部