unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Button2: TButton;<br> private<br><br> { Private declarations }<br> public<br> { Public declarations }<br> class procedure myselfmessage(var Msg: TMsg; var Handled: Boolean);<br><br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>class procedure TForm1.myselfmessage(var Msg: TMsg; var Handled: Boolean);<br>begin<br> if Msg.message = WM_QUIT then begin<br> ShowMessage('asdfds');<br> end;<br>end;<br><br><br>end.<br><br><br>program Project1;<br><br>uses<br> Forms,<br> Unit1 in 'Unit1.pas' {Form1};<br><br>{$R *.res}<br><br>begin<br> application.OnMessage := TForm1.myselfmessage;<br> Application.Initialize;<br><br><br> Application.CreateForm(TForm1, Form1);<br><br> Application.Run;<br>end.<br><br><br>看看有没有参考价值