X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/2d2676149292e4e388bb102a41a3d64349ac88ed..19e44013088ff80c11e1d7c045331b96f4dc41f0:/lmessages.pas?ds=sidebyside diff --git a/lmessages.pas b/lmessages.pas old mode 100755 new mode 100644 index a7bd01e..d5521e5 --- a/lmessages.pas +++ b/lmessages.pas @@ -4,7 +4,7 @@ ----------------------------------------------------------------------------- } //this unit provides a rough approximation of windows messages on linux -//it is usefull for multithreaded applications on linux to communicate back to +//it is useful for multithreaded applications on linux to communicate back to //the main lcore thread //This unit is *nix only, on windows you should use the real thing @@ -73,11 +73,13 @@ type const WS_EX_TOOLWINDOW = $80; WS_POPUP = longint($80000000); + CW_USEDEFAULT=$80000000; hinstance=nil; PM_REMOVE = 1; WM_USER = 1024; WM_TIMER = 275; INFINITE = syncobjs.infinite; + function getwindowlongptr(ahwnd:hwnd;nindex:integer) : taddrint; function setwindowlongptr(ahwnd:hwnd;nindex:integer;dwNewLong : taddrint) : taddrint; function DefWindowProc(ahWnd:HWND; auMsg:Integer; awParam:WPARAM; alParam:LPARAM):Integer; stdcall; @@ -103,6 +105,7 @@ uses {$i unixstuff.inc} type + tmessageintransit = class msg : tmsg; next : tmessageintransit; @@ -114,7 +117,7 @@ type waiting : boolean; lcorethread : boolean; nexttimer : ttimeval; - threadid : integer; + threadid : tthreadid; end; twindow=class hwnd : hwnd; @@ -131,22 +134,22 @@ var lcorelinkpiperecv : tlasio; windows : thashtable; //I would rather things crash immediately - //if they use an insufficiant size type + //if they use an insufficient size type //than crash after over four billion //windows have been made ;) nextwindowhandle : qword = $100000000; //findthreaddata should only be called while holding the structurelock -function findthreaddata(threadid : integer) : tthreaddata; +function findthreaddata(threadid : tthreadid) : tthreaddata; begin - result := tthreaddata(findtree(@threaddata,inttostr(threadid))); + result := tthreaddata(findtree(@threaddata,inttostr(taddrint(threadid)))); if result = nil then begin result := tthreaddata.create; result.messageevent := teventobject.create(nil,false,false,inttostr(taddrint(result))); result.nexttimer := tv_invalidtimebig; result.threadid := threadid; - addtree(@threaddata,inttostr(threadid),result); + addtree(@threaddata,inttostr(taddrint(threadid)),result); end; end; @@ -160,7 +163,7 @@ begin //writeln('freeing thread data object'); athreaddata.free; //writeln('deleting thread data object from hashtable'); - deltree(@threaddata,inttostr(athreaddata.threadid)); + deltree(@threaddata,inttostr(taddrint(athreaddata.threadid))); //writeln('finished deleting thread data'); end else begin //writeln('thread data is not unused'); @@ -232,7 +235,7 @@ begin //swriteln('duplicate window class registered with different settings'); raise exception.create('duplicate window class registered with different settings'); end else begin - //swriteln('duplicate window class registered with same settings, tollerated'); + //swriteln('duplicate window class registered with same settings, tolerated'); end; end else begin //swriteln('about to allocate memory for new windowclass'); @@ -289,10 +292,10 @@ begin window := twindow(findtree(@windows,inttostr(ahwnd))); if window <> nil then begin freemem(window.extrawindowmemory); - //writeln('aboute to delete window from windows structure'); + //writeln('about to delete window from windows structure'); deltree(@windows,inttostr(ahwnd)); //writeln('deleted window from windows structure'); - windowthreaddata := tthreaddata(findtree(@threaddata,inttostr(window.threadid))); + windowthreaddata := tthreaddata(findtree(@threaddata,inttostr(taddrint(window.threadid)))); if windowthreaddata <> nil then begin //writeln('found thread data scanning for messages to clean up');