首页  编辑  

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

Tags: /超级猛料/VCL/Form,窗体/FAQ/   Date Created:

]、。·ˉˇ¨〃々—~‖…’”〕〉》」』〗】∶!"'),.:;?]` 方法一:截获 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;