You'll notice that the top of the DDEPOP.C listing contains the line:
#include <dde.h>
This is the header file that includes the DDE messages and data structures.
This is followed in the DDEPOP.C listing by the structure called pop that contains all the two-character state codes, the 1970 population figures, the 1980 population figures, and a fourth field initialized with zeros that will contain the current population based on the system date and time.
The program also defines a second structure (called POPADVISE) using a typedef statement. I'll discuss later how this structure is used.
In WinMain, the program terminates if hPrevInstance is not equal to NULL. There is no reason for multiple copies of DDEPOP to be running under Windows. The program registers two window classes. The first has the class name ”DdePop“ used for the program's main window. The second has the class name ”DdePop.Server.“ This second class is used for the child windows that are created to maintain multiple DDE conversations. Each conversation requires its own child window based on this window class.
In this second window class, the cbWndExtra field of the WNDCLASS structure is set to hold two words per window. As you'll see, the first will be used to store the window handle of the client that the server window is communicating with. The second will be a handle to a global memory block that contains NUM_STATE structures of type POPADVISE.
After DDEPOP creates its main window, it explicitly sends the window a WM_TIMER message. The sole purpose of this message is to allow WndProc an opportunity to initialize the lPop field of the pop structure with the current population based on the lPop70 and lPop80 fields and the system date and time. The program also calls SetTimer to set a 5-second timer to periodically update the lPop field.
You'll notice that ShowWindow is called with the SW_SHOWMINNOACTIVE parameter and that WndProc returns 0 from the WM_QUERYOPEN message. This keeps DDEPOP displayed as an icon (similar to the FREEMEM program from Chapter 5).