Witam.
Piszę temat, gdyż nie mogę Sobie poradzić z wątkiem.
Jego kod wygląda tak:
unit Unit9;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Tlhelp32, StdCtrls, PsAPI, Vcl.Samples.Spin, Vcl.ExtCtrls, Math,
Vcl.Menus, MMSystem;
type
TAlarm = class(TThread)
private
protected
procedure Execute; override;
end;
var
Alarm:TAlarm;
implementation
uses Unit1;
procedure TAlarm.Execute;
begin
FreeOnTerminate := true;
while not self.terminated do
begin
if (Form1.Label7.Caption >= '100') then
begin
SNDPlaySound('Danger.wav', SND_FILENAME OR SND_ASYNC);
end;
end;
end;
Initialization
Alarm := TAlarm.Create(True);
end.
Chcę, by wątek sprawdzał mi label7 i jeżeli liczba w nim zapisana jest większa od 100 to żeby wył tak zwany alarm.
Checkbox wygląda tak:
procedure TForm1.CheckBox7Click(Sender: TObject);
begin
if Checkbox7.Checked then
begin
Alarm.Resume;
end
Else
begin
Alarm.Suspend;
end;
end;
Nie chcę tego robić w timerze, co by było łatwiejsze.
Proszę o pomoc.
Dziękuję