소스 검색

Improve SetTimer example.

Martijn Laan 1 년 전
부모
커밋
c7745fc3f8
1개의 변경된 파일16개의 추가작업 그리고 5개의 파일을 삭제
  1. 16 5
      Examples/CodeDll.iss

+ 16 - 5
Examples/CodeDll.iss

@@ -79,17 +79,28 @@ end;
 function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: Longword): Longword;
 external '[email protected] stdcall';
 
+function KillTimer(hWnd, nIDEvent: Longword): Bool;
+external '[email protected] 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;