simulate gettimeofday on windows
[lcore.git] / wmessages.pas
1 { Copyright (C) 2005 Bas Steendijk and Peter Green\r
2   For conditions of distribution and use, see copyright notice in zlib_license.txt\r
3   which is included in the package\r
4   ----------------------------------------------------------------------------- } \r
5       \r
6 unit wmessages;\r
7 //this unit contains varions functions and types to make it easier to write\r
8 //code that works with both real windows messages and lmessages\r
9 \r
10 interface\r
11 uses windows,messages,pgtypes;\r
12 type\r
13   thinstance=thandle;\r
14   thevent=thandle;\r
15 \r
16 //according to MS you are supposed to use get/setwindowlongptr to get/set\r
17 //pointers in extra window memory so your program can be built for win64, this\r
18 //is also the only interface to window memory that lmessages offers but delphi\r
19 //doesn't define it so alias it to getwindowlong here for win32.\r
20 {$ifndef win64} //future proofing ;)\r
21   function getwindowlongptr(ahwnd:hwnd;nindex:integer) : taddrint;\r
22   procedure setwindowlongptr(ahwnd:hwnd;nindex:integer;dwNewLong : taddrint);\r
23 {$endif}\r
24 function WaitForSingleEvent(hHandle: THandle; dwMilliseconds: DWORD): DWORD; stdcall;\r
25 implementation\r
26 {$ifndef win64}\r
27   function getwindowlongptr(ahwnd:hwnd;nindex:integer) : taddrint;\r
28   begin\r
29     result := getwindowlong(ahwnd,nindex);\r
30   end;\r
31   procedure setwindowlongptr(ahwnd:hwnd;nindex:integer;dwNewLong : taddrint);\r
32   begin\r
33     setwindowlong(ahwnd,nindex,dwnewlong);\r
34   end;\r
35 {$endif}\r
36 function WaitForSingleEvent(hHandle: THandle; dwMilliseconds: DWORD): DWORD; stdcall;\r
37 begin\r
38   result := waitforsingleobject(hhandle,dwmilliseconds);\r
39 end;\r
40 end.