
       MTASK: Multitasking demo for Windows 3.1 by Mark Gamber  3/30/93

   MTASK demonstrates two methods of letting other applications run while your
application is doing entensive work. Two dialog boxes are used. Both do a 20
second timed loop in the WM_INITDIALOG code. The NoFocusDlgProc() lets other
applications run while doing it's timed loop, but does not allow focus to be
changed to another application. You can test this by running the Clock and
watching the seconds update while the NoFocusDlgProc() is running. The second
method, as shown by FocusOkDlgProc(), allows the user to change focus to
another running application, except the parent window, of course.
   As can be seen in the FocusOkDlgProc(), you may want to protect your program
during a loop like this since it's possible for the user to close the dialog
box while still running. The easiest way, of course, is to disable the OK
button and System Menu before the loop executes and enable them again when the
loop is finished. You can also use PeekMessage() with PM_NOREMOVE and test the
message. If intended for the dialog window, it can be ignored. If not, then you
can call PeekMessage() again using PM_REMOVE and do the usual Translate and
Dispatch routine.
   Both of these routines are very simplistic. In real life, the Yield() and
PeekMessage() code would more than likely be within a for() loop to allow more
time to other applications. Basically, each time Yield()/PeekMessage() is
called, one application is allowed one time slice, which is often not enough if
the routine with the loop is lengthy.

   This code is public domain and may be freely distributed. The author makes
no guarentees. In using the code and program, the user assumes responsibility
for proper use and shall indemnify and hold harmless the author and software
from and damages, whether real or imagined.

