The Template.C source code begins with two include statements referencing, the Windows.H and Template.H headers.
#include <windows.h>
#include “template.h”
Notice that the template.h include statement uses quotation marks rather than angle brackets (<>). This identifies the include file as one located locally, as part of the application source code, rather than a system file that is found in the Developer Studio include directory.
#define APP_MENU “TemplateMenu”
#define APP_ICON “Template”
HANDLE hInst;
char szAppTitle[] = “Application Template”;
char szAppName[] = “Template”;
In the WinHello demo, only one string identifier was declared—in the WinMain procedure for the szAppClass—and all the other string references were entered directly as required.
For the Template demo, two strings and two defines are declared, both global to the entire program. This format was chosen for two reasons:
In some cases, the menu and icon names could also be declared as string variables. This format uses #define statements because there are circumstances where a NULL argument may be needed instead of strings (as you will see in Chapter 3).
In later examples, additional references will appear, similar to one of these two declaration styles and generally for the same reasons.
The balance of the Template.C source code is quite brief and contains only three functions: WinMain, WndProc, and AboutProc. The latter two are exported procedures and declared as such in Template.DEF.
The first of these, WinMain, is much briefer than its equivalent in the WinHello demo, even though both accomplish the same tasks. In Template’s version of the WinMain procedure, however, the provisions required to initialize the application class and to initialize application instances have been transferred as independent subprocedures to the Template.I include file. The second procedure, WndProc in this example, provides a skeletal structure for application message handling. In this example, only a few message-response provisions are included: the WM_COMMAND and IDM_ABOUT subcommand messages, and the WM_DESTROY message.
The third procedure, AboutProc, parallels the WndProc procedure in many respects but provides message handling for the About dialog box.