Improve SetTimer example.

This commit is contained in:
Martijn Laan 2024-05-26 15:32:49 +02:00
parent af81ab1871
commit c7745fc3f8
No known key found for this signature in database
GPG Key ID: E2DD568CF6098F6A

View File

@ -79,17 +79,28 @@ end;
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: Longword): Longword;
external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd, nIDEvent: Longword): Bool;
external 'KillTimer@user32.dll stdcall';
var
TimerCount: Integer;
TimerID, TimerCount: Integer;
procedure MyTimerProc(Arg1, Arg2, Arg3, Arg4: Longword);
begin
Inc(TimerCount);
WizardForm.BeveledLabel.Caption := ' Timer! ' + IntToStr(TimerCount) + ' ';
WizardForm.BeveledLabel.Visible := True;
if WizardForm <> nil then begin
Inc(TimerCount);
WizardForm.BeveledLabel.Caption := ' Timer! ' + IntToStr(TimerCount) + ' ';
WizardForm.BeveledLabel.Visible := True;
end;
end;
procedure InitializeWizard;
begin
SetTimer(0, 0, 1000, CreateCallback(@MyTimerProc));
TimerID := SetTimer(0, 0, 1000, CreateCallback(@MyTimerProc));
end;
procedure DeinitializeSetup;
begin
if TimerID <> 0 then
KillTimer(0, TimerID);
end;