win32: add 64bit safe version of callback and timer functions. Issue #23052

git-svn-id: trunk@39164 -
This commit is contained in:
blikblum 2012-10-25 14:19:27 +00:00
parent 98c3996b73
commit 384db6d21b
4 changed files with 13 additions and 5 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;