Newsgroups: comp.windows.ms.programmer
Path: utzoo!utgpu!watserv1!maytag!watstat.waterloo.edu!dmurdoch
From: dmurdoch@watstat.waterloo.edu (Duncan Murdoch)
Subject: Re: What does Yield do?
Message-ID: <1991May16.190243.27809@maytag.waterloo.edu>
Sender: news@maytag.waterloo.edu (News Owner)
Organization: University of Waterloo
References: <1991May16.121553.3876@maytag.waterloo.edu> <1095@venice.SEDD.TRW.COM>
Date: Thu, 16 May 1991 19:02:43 GMT
Lines: 35

In article <1095@venice.SEDD.TRW.COM> press@venice.sedd.trw.com (Barry Press) writes:
>In article <1991May16.121553.3876@maytag.waterloo.edu> dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes:
>>
>>I'm trying to civilize it by putting occasional calls to Yield into the 
>>loop, but it's ignoring mouse events..  If other windows have
>
>One of your problems may be that while Yield lets other programs process
>messages, it doesn't let YOUR program do so.  
>
>The problem this presents is this:  Assume your program has the focus.
>When some other program is to get the focus, you get sent a message
>(WM_KILLFOCUS, WM_FOCUS, WM_SETFOCUS, or something along those lines)
>that tells you you're losing it.

Thanks for the help (and thanks to Terrell for the SDK manual quote).  Yes,
that looks like what's happening.  What I've done, which seems to work, is
to write my own Yield that does one cycle through a standard message
processing loop:

procedure yield;
var
  msg : TMsg;
begin
  if Getmessage(msg,0,0,0) then
  begin
    Translatemessage(msg);
    Dispatchmessage(msg);
  end;
end;

As long as I call this frequently enough, things are fine.  (I have a 
window procedure that handles all the focus messages by passing them
on to the default handler.)

Duncan Murdoch
