🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #2686

Re: What does Yield do?

#2686
From: Barry Press
Date: Thu, 16 May 1991 16:20
27 lines
1787 bytes
In article <1991May16.121553.3876@maytag.waterloo.edu> dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes:
>
>I'm porting a DOS program to Windows (using TP for Windows), and am having 
>trouble getting it to be civilized.  It has some long loops where it 
>occasionally writes to one window; the original never gives up control,
>so in Windows everything else comes to a halt until it's done.
>
>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.

If I recall correctly, the other program won't get the focus (and, therefore,
process user input) until you process this message.

One way to fix this is to put a call not to Yield, but to Peek Message in
your loop, where the PeekMessage parameters are set to restrict things to
the focus change message.

-- 
Barry Press                                 Internet: press@venice.sedd.trw.com
Technical Details
Message-ID: <1095@venice.SEDD.TRW.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!trwind!venice!press
References: <1991May16.121553.3876@maytag.waterloo.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!trwind!venice!press
From: press@venice.SEDD.TRW.COM (Barry Press)
Newsgroups: comp.windows.ms.programmer
Subject: Re: What does Yield do?
Message-ID: <1095@venice.SEDD.TRW.COM>
Date: 16 May 91 16:20:13 GMT
References: <1991May16.121553.3876@maytag.waterloo.edu>
Reply-To: press@venice.sedd.trw.com (Barry Press)
Organization: TRW Systems Engineering & Development Division, Redondo Beach, CA
Lines: 27