PMPaintThread

From EDM2
Jump to: navigation, search

Description

Paint thread class: Allows to dump lengthy paint operations on a secondary thread.

What to do to use the class:

  1. Create the class (you'll want to derive another class and redefine the paint function).
  2. when creating the window that uses the class (in the create() func.) open a DC of the window, get a PS, create the paint thread, and if you want, you may produce a segment on the PS. (openSegment with drawing mode set to DM_RETAIN).
  3. When WM_PAINT is sent to the window, do default processing (i.e. erasing the window, then stop drawing in the paint thread, wait for ready flag (readySem posted), and post the triggerSem to trigger drawing.
  4. When exiting the window, kill the thread, (optionally calling stop and waiting for ready flag).

Note: it is not necessary to wait for the ready flag.