home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctchnqs / 1991 / number6 / apprun.src next >
Text File  |  1991-11-11  |  908b  |  25 lines

  1. { Listing 3:  A simplified (no translations) message loop }
  2.  
  3. procedure Application.Run
  4. var
  5.   Backgrnd: pointer;
  6.   Message:  TMessage;
  7. begin
  8.   Backgrnd := Dynamic(TypeOf(Self), di_Background);
  9.   { "di" for "dynamic index", of course.  (When in Windows, name   }
  10.   { like Windows.)  I use $7FFF, as it seems rather unlikely that  }
  11.   { any app will ever need to define so many internal messages.    }
  12.   if (@ Application.Background) = Backgrnd
  13.   {Is there a BACKGROUND method that actually does anything?}
  14.     then while GetMessage(Message, 0, 0, 0) do
  15.       {Nothing but respond to events}
  16.       DispatchMessage(Message)
  17.     else repeat
  18.      {Respond to events AND do background processing}
  19.      if PeekMessage(Message, 0, 0, 0, pm_Remove)
  20.        then DispatchMessage(Message)
  21.        else NiladicMethod(Backgrnd)(Self);
  22.         {Cheaper to do DMT lookup _once_}
  23.      until Message.Message = wm_Quit;
  24. end;
  25.