Dec 062017
 
C example of programming background activities in Windows 3.0.
File BACKGRND.ZIP from The Programmer’s Corner in
Category C Source Code
C example of programming background activities in Windows 3.0.
File Name File Size Zip Size Zip Type
BACKGRND.C 26085 6896 deflated
BACKGRND.DEF 554 337 deflated
BACKGRND.H 1520 584 deflated
BACKGRND.MAK 400 184 deflated
BACKGRND.RC 3028 964 deflated
Q71670.DOC 2656 1164 deflated

Download File BACKGRND.ZIP Here

Contents of the Q71670.DOC file


Q71670 INF: Background Processing with PeekMessage() Code Example
Microsoft Windows Software Development Kit (WINSDK)
3.00
MS-DOS

Summary:

BACKGRND is a sample program in the Software/Data Library that
demonstrates how to use a PeekMessage() loop to do background
processing in a Windows application. BACKGRND can be found in the
Software/Data Library by searching on the word BACKGRND, the Q number
of this article, or S13017. BACKGRND was archived using the PKware
file-compression utility.

More Information:

BACKGRND uses a PeekMessage() loop to do background processing. The
background task is to draw random rectangles. One "batch" of
rectangles is drawn each time through the PeekMessage() loop, and all
of the rectangles in each batch are drawn in the same color. This
provides a visual indication of how much background work is being done
before BACKGRND offers to yield.

Both the "batch size" and the total number of rectangles to be drawn
can be changed via the menu.

BACKGRND does not replace the main GetMessage() loop with a
PeekMessage() loop. Instead, it enters a PeekMessage() loop only when
the user chooses the Draw! menu item.

While drawing the rectangles, BACKGRND puts up a modeless dialog box
that:

1. Allows the user to cancel the background processing before all of
the rectangles have been drawn (by choosing the Cancel button)

2. Indicates both the total number of rectangles to be drawn and the
batch size

3. Displays a "gas gauge" that indicates the percentage of the
background job that has been completed

BACKGRND can be run along with another Windows application (for
example, Notepad) to illustrate the difference between "polite" and
"impolite" background processing.

If the batch size is set to a "polite" small value [for example, 10
rectangles each time through the PeekMessage() loop], the user can
easily type within Notepad while BACKGRND is drawing rectangles.
BACKGRND draws rectangles in the spare time slices between the
messages generated by the user's keystrokes, and calls PeekMessage()
often enough that the user will still find Notepad to be responsive.

If the batch size is set to an "impolite" large value [for example,
1000 rectangles each time through the PeekMessage() loop], BACKGRND
can complete its background job much more quickly, because there are
fewer calls to PeekMessage() and thus less overhead. However, a user
trying to type into Notepad will find the keyboard so unresponsive
that Notepad will be essentially useless.

Keywords: softlib

COPYRIGHT Microsoft Corporation, 1991.
Updated 91/05/24 03:44


 December 6, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)