Einfach gesagt, ich habe recht
.
Delphi-Quellcode:
var
Form1:TForm1;
myTimer:TMyTimer;
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.Text := DateTimeToStr( Now );
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
myTimer := TMyTimer.Create( 0 );
myTimer.OnTimer := Button1Click;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
myTimer.Free;
end;
ABER, die TimerCallback muss dann so aussehen ( LEIDER... ):
Delphi-Quellcode:
procedure TimerCallBack( Hwnd_ : HWND;
// handle of window for timer messages
uMsg :UINT;
// WM_TIMER message
idEvent :UINT;
// timer identifier <- das wird jetzt ignoriert....
dwTime :DWORD
// current system time
);
stdcall;
//var CallingTimer:TMyTimer;
begin
//CallingTimer := TMyTimer(idEvent);
//CallingTimer.DoTimerProc();
myTimer.DoTimerProc;
end;
und das nur weil nIDEvent Parameter ignoriert wird.
Zitat:
hWnd
Identifies the window to be associated with the timer. This window must be owned by the calling thread. If this parameter is NULL, no window is associated with the timer and the nIDEvent parameter is ignored.