The MTGDI sample is a demonstration of sharing GDI resources among multiple threads using the framework's single document interface (SDI) support for documents and views.
You can use the menu to add 1, 10, or 25 new threads at a time. Each thread displays either a moving ball, rectangle, or line in a random color.
MTGDI uses a set of CWinThread-derived classes, all of which are implemented in THREADS.CPP. The sample's own CGDIThread is the virtual base class for each of these GDI thread classes (one each for balls, rectangles, and lines). Since GDI resources cannot be shared among threads as MFC objects, this sample also demonstrates how to convert from standard GDI resources to MFC objects and back.
The application creates the desired number of threads when the user chooses to add new objects to those being displayed by the Thread menu. Each new object displayed is handled in its own thread. Any number of threads can be added to those already in progress. The number of threads currently being handled is shown in the title bar.
The threads are shut down all at once from the Thread menu, but you have a choice between whether this shutdown is done slowly or quickly. If there are fewer than 100 threads, it is difficult to tell the difference in speed between these two methods for MTGDI.
This sample demonstrates the following keywords:
You can find the MTGDI project files in the Wce\Samples\Mfc\MTGDI directory.
To build the MTGDI sample, follow the procedure described in Building the Sample Applications, selecting one or more of the following project configurations.