掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
TTimerでのKillTimerの使い方の疑問 (ID:47350)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
TTimerでのKillTimerの使い方の疑問 TTimerコンポーネントのKillTimer戻りがFalseを吐くので調べてみました GetLastError値は$00000000で内容は「この操作を正しく終了しました。」 推定原因 1. KillTimerの多重呼出 2.Application.MainForm.Visibleの前の呼び出し 3.Application.Terminated時の不完全な呼び出し 解決案 TTimer = class(TComponent) private FEnabled: Boolean; FTimerOn: Boolean;//追加(多重呼出禁止の為) ----------------------------------------------------------- constructor TTimer.Create(AOwner: TComponent); begin inherited Create(AOwner); FTimerOn := False;//追加 FEnabled := True; FInterval := 1000; ----------------------------------------------------------- procedure TTimer.UpdateTimer;//変更 begin if ((Application.MainForm <> nil) and (FInterval <> 0) and (not FEnabled) and (Application.MainForm.Visible)) or (Application.Terminated) then begin if FTimerOn then if KillTimer(FWindowHandle, 1) then FTimerOn := False; FEnabled := False; end; if (FInterval <> 0) and FEnabled and Assigned(FOnTimer) then if not FTimerOn then if SetTimer(FWindowHandle, 1, FInterval, nil) = 0 then raise EOutOfResources.Create(SNoTimers) else FTimerOn := True; end; エラーの内容ですと何の問題も無いですが 個人的妄想の解決案を上げました 感想があればよろしくお願いします。 以上
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.