Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Unterschied: WM_TIMER und TimerProc ? (https://www.delphipraxis.net/81568-unterschied-wm_timer-und-timerproc.html)

turboPASCAL 29. Nov 2006 14:22


Unterschied: WM_TIMER und TimerProc ?
 
Hi,

Isch hätt da mal 'n Problem...

Kann mir bitte mal jemand den Unterschied zwischen dem Aufruf von dem WM_TIMER - Ereignis und der
TimerProc erklären ?

Beispiel 1:

Delphi-Quellcode:
program TestOne;

// ...

function WndProc(hWnd: HWND; uMsg: UINT; wParam: wParam; lParam: LParam):
  lResult; stdcall;
begin
  result := 0;
  case uMsg of
    WM_CREATE:
      begin
        SetTimer(hWnd, IDC_TIMERID, 2000, nil);
      end;

    WM_TIMER: MachWas;
  //...
Beispiel 2:
Delphi-Quellcode:
program TestTwo;

// ...

function MyTimerProc(...) stdcall;
begin
  For X := 0 to Foo do
    MachMalWas;
end;

function WndProc(hWnd: HWND; uMsg: UINT; wParam: wParam; lParam: LParam):
  lResult; stdcall;
begin
  result := 0;
  case uMsg of
    WM_CREATE:
      begin
        SetTimer(hWnd, IDC_TIMERID, 2000, @MyTimerProc);
      end;

  //...

Luckie 29. Nov 2006 14:26

Re: Unterschied: WM_TIMER und TimerProc ?
 
Die Timer Callback liefert dir noch zusätzlich die zeit in Millisekunden seit dem Systemstart. Sollte man diese Braucher, erspart sich mit der Timer Callback einen Systemaufruf von GetTickCount. Das wäre für mich erstmal der offensichtliche Unterschied.

turboPASCAL 29. Nov 2006 14:42

Re: Unterschied: WM_TIMER und TimerProc ?
 
Aha, danke. Ich dachte in Hinsicht auf die Performxce bzw. "Aufrufgeschwindigkeit" / Sicherheit...


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:49 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz