The Template.RC script provides the basic elements required for the Template demo. We’ll discuss application resources, resource files, and resource scripts in detail in later chapters.
The Template demo requires three resources: a menu bar (TemplateMenu), a dialog box (AboutDlg), and an icon image (template.ico). Notice also that the Template.RC script includes a reference to the Template.H header file.
NOTE
In the resource script shown here, note the Pascal-like elements—particularly the BEGIN and END statements—which were alluded to at the beginning of this chapter.
//================================//
// Template.RC Resource Script //
//================================//
#include “windows.h”
#include “template.h”
TemplateMenu MENU
BEGIN
POPUP “&Help”
BEGIN
MENUITEM “&About Template...”, IDM_ABOUT
END
END
This section of the Template.RC script creates a simple menu bar with one pull-down menu titled Help (see Figure 2.1) with a single item, About Template..., which returns the command message value defined by IDM_ABOUT. Of course, most application menus are considerably more complex. We’ll get to these complexities in later chapters.
The IDM_ABOUT command message returned from the menu calls a dialog box that is also described in the resource script, as shown in the following lines:
AboutDlg DIALOG 22, 17, 144, 75
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION “About Template”
BEGIN
CONTROL “The Template application provides”, -1,
“STATIC”,
SS_CENTER | WS_CHILD | WS_VISIBLE | WS_GROUP,
14, 7, 115, 8
CONTROL “a generic template for designing”, -1,
“STATIC”,
SS_CENTER | WS_CHILD | WS_VISIBLE | WS_GROUP,
14, 18, 115, 8
CONTROL “Win98 applications.”, -1, “STATIC”,
SS_CENTER | WS_CHILD | WS_VISIBLE | WS_GROUP,
14, 29, 115, 8
CONTROL “OK”, IDOK, “BUTTON”, WS_GROUP, 56, 50, 32, 14
END
The AboutDlg dialog box described also appears in Figure 2.1.
Last, the resource script includes a reference to an .ICO image file, which contains the application icon.
Template ICON “template.ico”
Because binary images are not readily adaptable to the present format (the printed page), you will need to use an icon editor to create a sample icon image with the Template.ICO filename or select an appropriate image from any of the many available sources.
Figure 2.1: The About Template dialog box