unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
const
MyWm=WM_USER+100;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure MyWM1(var message:Tmessage);message MyWm;
end;
var
Form1: TForm1;
cancel:Boolean;
implementation
{$R *.DFM}
procedure Tform1.MyWM1(var message:Tmessage);
begin
Cancel:=false;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
msg:TMsg;
begin
i:=0;
Cancel:=true;
While Cancel do
begin
inc(i);
label1.Caption:=inttostr(i);
label1.Refresh;
if i=60000 then
i:=0;
while peekmessage(msg,0,0,0,PM_REMOVE) do
begin
if msg.message=MyWm then
Cancel:=false;
translatemessage(msg);
dispatchmessage(msg);
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
postmessage(form1.handle,MyWm,0,0);
end;
end.