unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm2 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FWorkHandle: THandle;
procedure WorkWindowProc(var message: TMessage);
public
{ Public declarations }
end;var
Form2: TForm2;const
WM_PROGRESS = WM_USER + $A;
EventTimer1 = 1020;
EventTimer2 = 1021;implementation{$R *.dfm}procedure TForm2.Button1Click(Sender: TObject);
begin
PostMessage(FWorkHandle, WM_PROGRESS, 0, 0);
end;procedure TForm2.FormCreate(Sender: TObject);
begin
FWorkHandle := AllocateHWnd(WorkWindowProc);
SetTimer(FWorkHandle, EventTimer1, 1000, nil);
SetTimer(FWorkHandle, EventTimer2, 100, nil);
end;procedure TForm2.FormDestroy(Sender: TObject);
begin
KillTimer(FWorkHandle, EventTimer1);
KillTimer(FWorkHandle, EventTimer2);
DeallocateHWnd(FWorkHandle);
end;procedure TForm2.WorkWindowProc(var message: TMessage);
begin
case message.Msg of
WM_PROGRESS:
Caption := 'hello WM_BURNPROGRESS';
WM_COPYDATA:
Caption := 'hello WM_COPYDATA';
WM_TIMER:
begin
case message.WParam of
EventTimer1:
Caption := 'hello WM_TIMER Event1 ' + IntToStr(GetTickCount);
EventTimer2:
Caption := 'hello WM_TIMER Event2 ' + IntToStr(GetTickCount);
end;
end;
else
//Dispatch(message);
end;
end;end.