Thema: Delphi Timer ohne Formular

Einzelnen Beitrag anzeigen

Benutzerbild von sniper_w
sniper_w

Registriert seit: 11. Dez 2004
Ort: Wien, Österriech
893 Beiträge
 
Delphi 6 Enterprise
 
#10

Re: Timer ohne Formular

  Alt 27. Nov 2005, 09:37
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.
Katura Haris
Es (ein gutes Wort) ist wie ein guter Baum, dessen Wurzel fest ist und dessen Zweige in den Himmel reichen.
  Mit Zitat antworten Zitat