add wmessages.pas (conviniance unit to make it easier to write code that works with...
authorplugwash <plugwash@p10link.net>
Sun, 15 Feb 2009 03:25:51 +0000 (03:25 +0000)
committerplugwash <plugwash@p10link.net>
Sun, 15 Feb 2009 03:25:51 +0000 (03:25 +0000)
messages and lmessages)

git-svn-id: file:///svnroot/lcore/trunk@40 b1de8a11-f9be-4011-bde0-cc7ace90066a

wmessages.pas [new file with mode: 0644]

diff --git a/wmessages.pas b/wmessages.pas
new file mode 100644 (file)
index 0000000..fed9259
--- /dev/null
@@ -0,0 +1,35 @@
+unit wmessages;\r
+//this unit contains varions functions and types to make it easier to write\r
+//code that works with both real windows messages and lmessages\r
+\r
+interface\r
+uses windows,messages,pgtypes;\r
+type\r
+  thinstance=thandle;\r
+  thevent=thandle;\r
+\r
+//according to MS you are supposed to use get/setwindowlongptr to get/set\r
+//pointers in extra window memory so your program can be built for win64, this\r
+//is also the only interface to window memory that lmessages offers but delphi\r
+//doesn't define it so alias it to getwindowlong here for win32.\r
+{$ifndef win64} //future proofing ;)\r
+  function getwindowlongptr(ahwnd:hwnd;nindex:integer) : taddrint;\r
+  procedure setwindowlongptr(ahwnd:hwnd;nindex:integer;dwNewLong : taddrint);\r
+{$endif}\r
+function WaitForSingleEvent(hHandle: THandle; dwMilliseconds: DWORD): DWORD; stdcall;\r
+implementation\r
+{$ifndef win64}\r
+  function getwindowlongptr(ahwnd:hwnd;nindex:integer) : taddrint;\r
+  begin\r
+    result := getwindowlong(ahwnd,nindex);\r
+  end;\r
+  procedure setwindowlongptr(ahwnd:hwnd;nindex:integer;dwNewLong : taddrint);\r
+  begin\r
+    setwindowlong(ahwnd,nindex,dwnewlong);\r
+  end;\r
+{$endif}\r
+function WaitForSingleEvent(hHandle: THandle; dwMilliseconds: DWORD): DWORD; stdcall;\r
+begin\r
+  result := waitforsingleobject(hhandle,dwmilliseconds);\r
+end;\r
+end.
\ No newline at end of file