diff --git a/lcl/interfaces/win32/win32callback.inc b/lcl/interfaces/win32/win32callback.inc index 2f77ea5e4a..c3d0991b69 100644 --- a/lcl/interfaces/win32/win32callback.inc +++ b/lcl/interfaces/win32/win32callback.inc @@ -2728,7 +2728,7 @@ end; Calls the timerfunction in the Timer Object in the LCL ------------------------------------------------------------------------------} -procedure TimerCallBackProc(window_hwnd : hwnd; msg : DWORD; idEvent: UINT; dwTime: DWORD); stdcall; +procedure TimerCallBackProc(window_hwnd : hwnd; msg : DWORD; idEvent: UINT_PTR; dwTime: DWORD); stdcall; Var TimerInfo: PWin32TimerInfo; n: Integer; diff --git a/lcl/interfaces/win32/win32def.pp b/lcl/interfaces/win32/win32def.pp index 609d4f894a..a5ab2d3cf5 100644 --- a/lcl/interfaces/win32/win32def.pp +++ b/lcl/interfaces/win32/win32def.pp @@ -40,7 +40,7 @@ type { lazarus win32 Interface definition for additional timer data needed to find the callback} PWin32TimerInfo = ^TWin32Timerinfo; TWin32TimerInfo = record - TimerID: UINT; // the windows timer ID for this timer + TimerID: UINT_PTR; // the windows timer ID for this timer TimerFunc: TWSTimerProc; // owner function to handle timer end; diff --git a/lcl/interfaces/win32/win32extra.pas b/lcl/interfaces/win32/win32extra.pas index d22b63f22b..43b4d384b1 100644 --- a/lcl/interfaces/win32/win32extra.pas +++ b/lcl/interfaces/win32/win32extra.pas @@ -410,6 +410,14 @@ const SHGFI_LARGEICON = $000000000; SHGFI_ICON = $000000100; +type + //64bit safe Timer functions and callback + //todo: remove as soon the last supported fpc version has updated header (rev 22526) + TIMERPROC = procedure (hWnd: HWND; uMsg: UINT; idEvent: UINT_PTR; dwTime: DWORD); stdcall; + + function SetTimer(hWnd:HWND; nIDEvent:UINT_PTR; uElapse:UINT; lpTimerFunc: TIMERPROC): UINT_PTR; external 'user32' name 'SetTimer'; + function KillTimer(hWnd:HWND; uIDEvent:UINT_PTR):WINBOOL; external 'user32' name 'KillTimer'; + implementation uses diff --git a/lcl/interfaces/win32/win32object.inc b/lcl/interfaces/win32/win32object.inc index 5ce1dcf79b..9c4f2e7225 100644 --- a/lcl/interfaces/win32/win32object.inc +++ b/lcl/interfaces/win32/win32object.inc @@ -562,7 +562,7 @@ begin if (Interval > 0) and (TimerFunc <> nil) then begin New(TimerInfo); TimerInfo^.TimerFunc := TimerFunc; - TimerInfo^.TimerID := Windows.SetTimer(0, 0, Interval, @TimerCallBackProc); + TimerInfo^.TimerID := Win32Extra.SetTimer(0, 0, Interval, @TimerCallBackProc); if TimerInfo^.TimerID=0 then dispose(TimerInfo) else begin @@ -587,9 +587,9 @@ begin while (n>0) do begin dec(n); TimerInfo := FTimerData[n]; - if (TimerInfo^.TimerID=UINT(TimerHandle)) then + if (TimerInfo^.TimerID=UINT_PTR(TimerHandle)) then begin - Result := Boolean(Windows.KillTimer(0, UINT(TimerHandle))); + Result := Boolean(Win32Extra.KillTimer(0, UINT_PTR(TimerHandle))); FTimerData.Delete(n); Dispose(TimerInfo); end;