Создаю таймер путем timeSetEvent. Вот код:
| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, MMSystem, ExtCtrls;
type TForm1 = class(TForm) GroupBox4: TGroupBox; txtTimeInterval: TEdit; cmbTimeStart: TButton; lstTimes: TListBox; procedure cmbTimeStartClick(Sender: TObject); private { Private declarations }
public { Public declarations } // procedure TimerProc(uTimerID, uMessage: UINT; dwUser, dw1, dw2: DWORD); stdcall; end;
var Form1: TForm1;
implementation {$R *.dfm} var timerID: UINT;
function timeGetMinPeriod(): DWORD; var time: TTimeCaps; begin timeGetDevCaps(Addr(time), SizeOf(time)); timeGetMinPeriod := time.wPeriodMin; end;
procedure TimerProc(uTimerID, uMessage: UINT; dwUser, dw1, dw2: DWORD) stdcall; begin Form1.lstTimes.Items.Add(IntToStr(timeGetTime())); end;
procedure TForm1.cmbTimeStartClick(Sender: TObject); begin if cmbTimeStart.Caption = 'Start' then begin txtTimeInterval.Enabled := False; cmbTimeStart.Caption := 'Stop'; lstTimes.Clear; timerID := timeSetEvent(StrToInt(txtTimeInterval.Text), timeGetMinPeriod(), TimerProc, 0, TIME_CALLBACK_FUNCTION or TIME_PERIODIC) end else begin txtTimeInterval.Enabled := True; cmbTimeStart.Caption := 'Start'; timeKillEvent(timerID); end; end;
|
Суть в том, что в процедуру TimerProc нужно объявить в public, но это ведет к ошибке в синтаксисе, как быть? |