我好像明白你的意思了,你大概是想拦截窗体最小化的消息,我估计窗体右上角的最小化按钮和左上角的
系统菜单中的最小化菜单,你都拦截成功了,现在就缺少任务栏上的最小化菜单了
可以这样,新建一个工程,在Form上放置一个TApplicationEvents控件,在Additional页上,下面是代码,
其中的不同就是作用的对象不一样
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
AppEvnts;
type
TForm1 = class(TForm)
ApplicationEvents1: TApplicationEvents;
procedure ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
private
{ Private declarations }
procedure wmsyscommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.wmsyscommand(var Msg: TWMSysCommand);
begin
if Msg.CmdType = SC_MINIMIZE then
ShowMessage('最小化');
inherited;
end;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if Msg.message = WM_SYSCOMMAND then
begin
if Msg.wParam = SC_MINIMIZE then
begin
ShowMessage('最小化');
inherited;
end;
end;
end;
end.