http://www.delphi2007.net/DelphiVCL/html/delphi_20061226141648106.html
我想在点击窗口最小化按钮时触发某个事件,请教我该怎么做???
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
ApplicationEvents1: TApplicationEvents;
procedure ApplicationEvents1Minimize(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);
begin
//这里写
end;
end.
可以用一个时间控件,判断是否被最小化,就行了...
public
{ Public declarations }
procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);
begin
if (Msg.CmdType = SC_MINIMIZE) or (Msg.CmdType = SC_MAXIMIZE) then
begin
// your code ............
showmessage('hello');
end;
DefaultHandler(Msg);
end;
madyak的方法好像不行,可能是我这边程序的问题,用hongqi162的方法搞定了,感谢各位!
给分
ApplicationEvents1
是控件面板上additional上的一个组件