X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/d63fdd677fc6ab221d92999630627bd1a0b8afd4..19e44013088ff80c11e1d7c045331b96f4dc41f0:/wcore.pas?ds=inline

diff --git a/wcore.pas b/wcore.pas
old mode 100755
new mode 100644
index 928486f..2c07d50
--- a/wcore.pas
+++ b/wcore.pas
@@ -1,8 +1,3 @@
-{ Copyright (C) 2005 Bas Steendijk and Peter Green
-  For conditions of distribution and use, see copyright notice in zlib_license.txt
-  which is included in the package
-  ----------------------------------------------------------------------------- }
-
 unit wcore;
 
 {
@@ -39,7 +34,7 @@ interface
       initialdone:boolean;
       prevtimer:tltimer;
       nexttimer:tltimer;
-      interval:integer;        {miliseconds, default 1000}
+      interval:integer;        {milliseconds, default 1000}
       nextts:integer;
       property enabled:boolean read fenabled write setenabled;
       constructor create(aowner:tcomponent);override;
@@ -63,6 +58,7 @@ procedure addtask(ahandler:ttaskevent;aobj:tobject;awparam,alparam:longint);
 procedure disconnecttasks(aobj:tobject);
 procedure exitmessageloop;
 procedure processmessages;
+procedure wcoreinit;
 
 var
   onshutdown:procedure(s:ansistring);
@@ -83,7 +79,7 @@ const
 var
   hwndwcore:hwnd;
   firsttimer:tltimer;
-  timesubstract:integer;
+  timesubtract:integer;
   firsttask,lasttask,currenttask:tltask;
 
 procedure tlcomponent.release;
@@ -148,13 +144,13 @@ begin
   end;
 
   tvnow := timegettime;
-  if (tvnow and ((-1) shl rollover_bits)) <> timesubstract then begin
+  if (tvnow and ((-1) shl rollover_bits)) <> timesubtract then begin
     currenttimer := firsttimer;
     while assigned(currenttimer) do begin
       dec(currenttimer.nextts,(1 shl rollover_bits));
       currenttimer := currenttimer.nexttimer;
     end;
-    timesubstract := tvnow and ((-1) shl rollover_bits);
+    timesubtract := tvnow and ((-1) shl rollover_bits);
   end;
   tvnow := tvnow and ((1 shl rollover_bits)-1);
 
@@ -221,7 +217,7 @@ begin
     end else begin
       currenttasklocal := currenttask; //needed in case called from a task
     end;
-    // note i don't bother to sestroy the links here as that will happen when
+    // note i don't bother to destroy the links here as that will happen when
     // the list of tasks is processed anyway
     while assigned(currenttasklocal) do begin
       if currenttasklocal.obj = aobj then begin
@@ -272,22 +268,17 @@ function MyWindowProc(
 var
     MsgRec : TMessage;
     a:integer;
-    handled:boolean;
 begin
   Result := 0;  // This means we handled the message
 
-  handled := false;
-
   {MsgRec.hwnd    := ahWnd;}
   MsgRec.wParam  := awParam;
   MsgRec.lParam  := alParam;
 
-  if (ahwnd = hwndwcore) then begin
-   dotasks;
-   case auMsg of
+  dotasks;
+  case auMsg of
     {$ifndef threadtimer}
     WM_TIMER: begin
-      handled := true;
       if msgrec.wparam = timerid_wcore then begin
         a := wcore_timehandler;
         killtimer(hwndwcore,timerid_wcore);
@@ -299,15 +290,14 @@ begin
     {WINMSG_TASK:dotasks;}
 
     WM_CLOSE: begin
-      handled := true;
+      {}
     end;
     WM_DESTROY: begin
-      handled := true;
+      {}
     end;
-   end;
+  else
+      Result := DefWindowProc(ahWnd, auMsg, awParam, alParam)
   end;
-
-  if not handled then Result := DefWindowProc(ahWnd, auMsg, awParam, alParam)
 end;
 
 
@@ -323,11 +313,8 @@ var
                                  lpszMenuName  : nil;
                                  lpszClassName : 'wcoreClass');
 
-procedure messageloop;
-var
-  MsgRec : TMsg;
+procedure wcoreinit;
 begin
-
   if Windows.RegisterClass(MyWindowClass) = 0 then halt;
   //writeln('about to create wcore handle, hinstance=',hinstance);
   hwndwcore := CreateWindowEx(WS_EX_TOOLWINDOW,
@@ -350,6 +337,14 @@ begin
   {$endif}
 
 
+end;
+
+procedure messageloop;
+var
+  MsgRec : TMsg;
+
+begin
+
   while GetMessage(MsgRec, 0, 0, 0) do begin
     TranslateMessage(MsgRec);
     DispatchMessage(MsgRec);
@@ -370,12 +365,13 @@ end;
 
 function ProcessMessage : Boolean;
 var
-    Msg : TMsg;
+    MsgRec : TMsg;
 begin
     Result := FALSE;
-    if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then begin
+    if PeekMessage(MsgRec, 0, 0, 0, PM_REMOVE) then begin
       Result := TRUE;
-      DispatchMessage(Msg);
+      TranslateMessage(MsgRec);
+      DispatchMessage(MsgRec);
     end;
 end;
 
@@ -386,3 +382,4 @@ end;
 
 
 end.
+