|
|
1.1 root 1: ========================================================================
2: MICROSOFT FOUNDATION CLASS LIBRARY : ABOUT2 EXAMPLE PROGRAM
3: ========================================================================
4:
5: This application is exactly like the "About2" sample written by
6: Charles Petzold in his book, "Programming Windows." This version was
7: written in C++ and uses the Foundation classes. Compare the code of
8: these two versions to see how Windows applications written in C can be
9: adapted to use the features of the Microsoft Foundation Class Library.
10:
11: MAKEFILE.
12: ABOUT2.MAK
13: ABOUT2.STS
14: These describe the compile process for the NMAKE tool and the
15: Programmer's Workbench. MAKEFILE is an NMAKE-compatible makefile,
16: while ABOUT2.MAK and ABOUT2.STS are the PWB-compatible makefile and
17: PWB status file, respectively.
18:
19: ABOUT2.H
20: ABOUT2.CPP
21: These two files make up the entire behavior of the application.
22: The application's classes are declared in the ABOUT2.H header
23: file, and the member functions and message maps are defined in
24: ABOUT2.CPP.
25:
26: Note that the CAbout2Dlg class's constructor, declared in ABOUT2.H,
27: uses the constructor of the base class, CModalDialog (a Foundation
28: class). Normally, the CModalDialog's constructor requires the name
29: of the dialog template resource. CAbout2Dlg objects will always be
30: associated with the "AboutBox" template (found in ABOUT2.RC), so
31: the new constructor supplies this name explicitly. Only the parent
32: window argument is then required by the creator of these objects.
33:
34: The CAbout2Dlg also has some member variables. These variables
35: hold the state of the current color and figure, for the duration of
36: the dialog. When the dialog is invoked, the global variables
37: nCurrentColor and nCurrentFigure are copied to these member
38: variables, and if the user presses OK in the dialog, they are
39: copied back into the global variables. A modal dialog box should
40: not modify the actual variables, but rather keep a separate copy
41: that can be disposed of in case the dialog's Cancel button is
42: pushed.
43:
44: A function is defined in ABOUT2.CPP which is not a member of either
45: of the two classes in the application. This is called Paint, and
46: it is used by both classes to draw a given figure in a given color
47: in any window's display context. The dialog calls Paint to draw the
48: figure according to the settings that the user makes in the dialog.
49: Once the dialog is dismissed, the frame window uses Paint to draw
50: the same figure in its client area.
51:
52: (For the extremely observant: you may notice that the Paint
53: function is slightly different in the C++ version from Charles
54: Petzold's original PaintWindow. The original version always
55: creates a new display context in which to draw. This version takes
56: a display context (such as the CPaintDC of the frame window) if one
57: is available, and creates a CDC if none is given. This avoids
58: obtaining and releasing extra display contexts from Windows.
59: Painting during an OnPaint/WM_PAINT message should be done with the
60: display context provided by CPaintDC/BeginPaint, to avoid unwanted
61: flashing.)
62:
63: RESOURCE.H
64: This file defines control IDs used in the About dialog box,
65: and the application's main window menu bar.
66:
67: ABOUT2.ICO
68: This is an icon file, which is used by the frame window, and also
69: appears in the About dialog box.
70:
71: ABOUT2.RC
72: This is a listing of all of the Microsoft Windows resources which
73: the program uses. It includes two resources: the icon found in
74: ABOUT2.ICO, and the application's main menu.
75:
76: ABOUT2.DLG
77: This file contains dialog control content and layout information.
78: It was generated directly by the DLGEDIT dialog editor, part of
79: the Microsoft Windows 3.1 Software Development Kit. ABOUT2.DLG is
80: processed by the Microsoft Windows Resource Compiler (it is
81: included by ABOUT2.RC).
82:
83: ABOUT2.DEF
84: A typical module definition file, used by LINK to set specific
85: application information in the executable file.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.