|
|
1.1 root 1: ========================================================================
2: MICROSOFT FOUNDATION CLASS LIBRARY : EXAMPLE CODE
3: ========================================================================
4:
5: I. Introduction
6:
7: This directory contains all of the Microsoft Foundation Class (MFC)
8: library example programs, which highlight many object-oriented
9: Windows programming techniques and class library features. Each
10: example is a complete and functional program that explores
11: different aspects of the library.
12:
13: These programs are useful as learning tools, when used in conjunction
14: with the MFC reference documentation. You can take the code provided
15: and experiment with it. One group of sample programs, in the TUTORIAL
16: subdirectory, supplements the MFC Tutorial and should be studied in
17: conjunction with that document.
18:
19: Each subdirectory has both PWB-compatible and NMAKE-compatible makefiles.
20: The PWB makefiles can be identified by the .MAK file extension. NMAKE
21: makefiles are called 'makefile', with the exception of the TUTORIAL
22: subdirectory (the difference is explained in TUTORIAL\README.TXT).
23:
24: -----------------------------------------------------------------------
25: Windows and C runtime libraries referenced by the makefiles should
26: be installed as part of the NT setup. These libraries can be found
1.1.1.2 root 27: in \MSTOOLS\LIB.
1.1 root 28: -------------------------------------------------------------------------
29:
30: II. Compiling sample programs with Microsoft NMAKE
31:
32: To compile a sample program with NMAKE:
33:
34: 1. Ensure you have the appropriate C runtime and Foundation
1.1.1.2 root 35: runtime libraries. All MFC library variants necessary to build
1.1 root 36: the samples are provided in binary form in MFC\LIB.
37:
38:
39: 2. Ensure you have set up your LIB, INCLUDE, and PATH environment variables
40: appropriately. For example:
41:
1.1.1.2 root 42: set LIB=C:\MSTOOLS\LIB;C:\MSTOOLS\MFC\LIB
43: set INCLUDE=C:\MSTOOLS\H;C:\MSTOOLS\MFC\INCLUDE
44: set PATH=%PATH%;C:\MSTOOLS\BIN
1.1 root 45:
46: Remember you must put the MFC\LIB and MFC\INCLUDE directories in
47: your LIB and INCLUDE paths, respectively, if you wish to compile
48: Foundation applications.
49:
50: 3. Change your working directory to the appropriate sample file
51: directory and invoke NMAKE.
52:
53: In most cases, invoking NMAKE with no arguments will compile and
54: link the retail version of that directory's sample application.
55: If you wish to build the debug version, specify 'DEBUG=1' on the
56: NMAKE command line. If you want to remove object, compiled resource,
57: and executable files, specify the 'clean' target. For example:
58:
1.1.1.2 root 59: cd \mstools\mfc\samples\about2
60: nmake ' creates retail version of about2.exe
1.1 root 61: nmake clean ' removes about2.exe/.obj/.res
1.1.1.2 root 62: nmake DEBUG=0 ' creates retail version of about2.exe
1.1 root 63: nmake clean ' removes about2.exe/.obj/.res
1.1.1.2 root 64: nmake DEBUG=1 ' creates debug version of about2.exe
1.1 root 65:
66: Object and resource files are created in the current directory.
67:
68: Compilation procedures for the tutorial subdirectory are slightly
69: different than is documented here. See MFC\SAMPLES\TUTORIAL\README.TXT
70: for more information.
71:
72: NOTE: See technical note MFC\DOC\TN007.TXT for special information
73: on setting up your Windows environment to handle Foundation library
74: debugging output.
75:
76:
77: -----------------------------------------------------------------------
78:
79: III. Samples
80:
81: Here is a list of the sample directories and an overview of their
82: content. See below for more detailed explanations
83:
84: ABOUT2 simple dialog box example.
85: CHART a simple bar/line charting application.
86: CTRLTEST a control test driver showing custom controls.
87: FILEVIEW a simple text file viewer.
88: HELLO basic application described in the MFC Tutorial.
89: HELLOAPP an extremely simple MFC application.
90: MDI demonstrates how to program to the MFC MDI interface.
91: MINMDI a bare-bones MDI application.
92: MINSVR a minimal OLE server application.
93: MINSVRMI a minimal OLE server application with multiple inheritance.
94: MULTIPAD an MDI NOTEPAD application.
95: OCLIENT an example of an Object Linking and Embedding (OLE) client.
96: OSERVER a simple OLE server application (called BIBREF)
97: SHOWFONT a font attribute viewer.
98: TEMPLDEF a non-Windows tool for expanding C++ templates.
99: TRACER a Windows utility to view and set diagnostic trace options.
100: TUTORIAL source for tutorial examples.
101:
102: -------------------------------------------------------------------------
103:
104: ABOUT2\ABOUT2.EXE
105:
106: This program is a re-implementation of the ABOUT program found in
107: Charles Petzold's book, "Programming Windows"; it has been written
108: using C++ and the Foundation classes. ABOUT2 allows you to draw
109: either a rectangle or an ellipse in one of several colors in the
110: client area of a application main window. The source code
111: illustrates the following concepts:
112:
113: - Simple Foundation application structuring.
114: - Simple dialog box initialization and management.
115: - Graphics Device Interface (GDI) wrapper classes.
116:
117: -------------------------------------------------------------------------
118:
119: CHART\CHART.EXE
120:
121: This program implements a simple bar/line charting application.
122: You can enter a data set (list of integers), display the data in
123: bar or line chart form, print the chart, save the data to disk,
124: and read in previously saved data. The source code illustrates
125: the following concepts:
126:
127: - Dialog box management.
128: - Document state management (dirty, clean).
129: - Using GDI calls to draw a graph to a device context.
130: - Using Foundation CFile and CArchive classes to save and
131: restore user data.
132: - Printing.
133:
134: -------------------------------------------------------------------------
135:
136: CTRLTEST\CTRLTEST.EXE
137:
138: The main application (in DCONTROL.H, DCONTROL.CPP and DCONTROL.RC)
139: provides a simple frame window with a single menu to drive the tests.
140: This can be easily extended to drive additional tests.
141:
142: All the examples are based off a the class CParsedEdit which
143: is derived from the standard Windows CEdit class. CParsedEdit
144: provides a simple keyboard input filter to only allow numbers,
145: letters, control characters, combinations of the above or any
146: characters.
147:
148: This sample also includes MUSCROLL.DLL, the "micro scrolling"
149: custom control provided in the Windows 3.1 SDK, as well as tests
150: for Pen Windows edit items (requires Windows for Pen).
151:
152: The source code illustrates the following concepts:
153:
154: - example parsed edit control (CParsedEdit) derived from
155: the standard Windows CEdit class.
156: - bitmap buttons
157: - owner draw/self draw controls
158: - owner draw/self draw menus
159: - using C++ to create controls for a dialog using Create
160: member functions for the controls (not recommended,
161: DERTEST.CPP, DERTEST.DLG)
162: - exporting custom controls and registering a new WndClass
163: so the controls can be used by the dialog manager
164: (the "PAREDIT" control class used in WCLSTEST.CPP
165: and WCLSTEST.DLG). These controls can be edited with the
166: SDK dialog editor (DLGEDIT.EXE) as custom controls
167: by typing in the class name "PAREDIT" and the
168: hex representation of the PES_ styles.
169: - using SubclassWindow/SubclassDlgItem to dynamically
170: subclass a dialog control to add specialized behaviour
171: (SUBTEST.CPP, SUBTEST.DLG).
172: - example of an external control packed as a DLL (MUSCROLL.DLL)
173: being used by C++ code with a special C++ wrapper class.
174: - an example of a spin button using the external MUSCROLL.DLL.
175: - examples of Windows for Pen special edit controls
176:
177: more advanced topics:
178: - ON_CONTROL handler (in WCLSTEST.CPP responding to new
179: control notification PEN_INVALIDCHAR).
180: - example of how style bits (PES_ style bits for the parsed
181: edit) can be stripped off before the normal CEdit
182: control is created.
183:
184: The source code to this application should be read along with
185: Foundation technical note 14 (MFC\DOC\TN014.TXT) describing
186: custom controls and other topics.
187:
188:
189: -------------------------------------------------------------------------
190:
191: FILEVIEW\FILEVIEW.EXE
192:
193: This program implements a simple text file viewer. Unlike
194: Windows NotePad, this program places no limit on the size
195: of the text file that may be viewed. This program is for
196: viewing text files only, and not editing them. The source code
197: illustrates the following concepts:
198:
199: - Foundation application structuring.
200: - Use of the Foundation file classes as base
201: classes for derivation and specialization.
202: - Use of the GDI classes for graphical output.
203: - Use of Message Maps for handling window scrolling.
204:
205:
206: -------------------------------------------------------------------------
207:
208: HELLO\HELLO.EXE
209:
210: Described in the MFC Tutorial, this application shows the basics of
211: using the Microsoft Foundation Class Library to write applications
212: for the Microsoft Windows environment. This application creates and
213: displays a fully-functional frame window, which in turn displays a
214: text string in its center. The source code illustrates the following
215: concepts:
216:
217: - Simple Foundation application structuring.
218: - Integrating Windows resources with your application.
219:
220: -------------------------------------------------------------------------
221:
222: HELLOAPP\HELLOAPP.EXE
223:
224: This is an extremely simple MFC application that simply creates a
225: main frame window with the caption 'Hello World!'. It is compiled
226: using retail libraries only.
227:
228: -------------------------------------------------------------------------
229:
230: MDI\MDI.EXE
231:
232: The MDI application demonstrates how to program to the MFC wrapper of
233: the Windows Multiple Document Interface (MDI) wrapper. When started,
234: the MDI application provides an MDI frame window, and two kinds of MDI
235: child windows that you may open within the frame. One child window
236: is similar to the HELLO example program (it displays "Hello World"
237: in its client area). The other kind of child window contains a
238: bouncing ball. The source code illustrates the following concepts:
239:
240: - Foundation MDI application structuring.
241: - Coordinating MDI frame and child classes.
242: - Using Windows timers.
243: - Using the CBitmap class for constructing and drawing a
244: bit pattern into a device context.
245:
246: -------------------------------------------------------------------------
247:
248: MINMDI\MINMDI.EXE
249:
250: This is a bare-bones MDI application that concentrates on showing the
251: minimum work needed to set up and maintain MDI child windows within
252: an MDI frame window. You can use this application as a starting point
253: for your own experimentation with the MDI interface. The source code
254: illustrates the following concepts:
255:
256: - Foundation MDI application structuring.
257: - Coordinating MDI frame and child classes.
258:
259: -------------------------------------------------------------------------
260:
261: MINSVR\MINSVR.EXE
262:
263: MINSVR is a minimal OLE server application that implements
264: a graphical ellipse drawing. When running MINSVR *directly* (from
265: the program manager, file manager, or an icon), MINSVR is registered
266: with the registration data base. YOU MUST RUN MINSVR DIRECTLY before
267: you can use it with other OLE programs. Once you have run MINSVR
268: directly, you can use it with OLE Clients where it provides basic
269: embeddable object services.
270:
271: The source code illustrates the following concepts:
272:
273: - Constructing a minimal OLE server
274: - Programming with the MFC OLE classes
275: - Supporting embedded objects
276:
277: It is highly recommended that you read Foundation technical notes 8, 9,
278: and 10 (MFC\DOC\TN008.TXT, etc.) for more information on the MFC OLE
279: classes and constructing OLE clients and servers using MFC.
280:
281:
282: -------------------------------------------------------------------------
283:
284: MINSVRMI\MINSVRMI.EXE
285:
286: MINSVRMI is a simple OLE server application that implements a
287: graphical elliptical drawing. It is the same program as MINSVR
288: except it is implemented using multiple inheritance. When MINSVRMI is
289: *directly* run, it registers itself with the registration database.
290: YOU MUST RUN MINSVRMI directly before using it with other OLE
291: programs. When run from an OLE client, MINSVRMI allows you to embed
292: objects in the client application's document.
293:
294: The source code illustrates the following concepts:
295:
296: - Constructing a minimal OLE server
297: - Programming with the MFC OLE classes
298: - Using multiple inheritance with MFC and MFC OLE classes
299: - Supporting embedded objects
300:
301: It is highly recommended that you read Foundation technical notes 8, 9,
302: and 10 (MFC\DOC\TN008.TXT, etc.) for more information on the MFC OLE
303: classes and constructing OLE clients and servers using MFC.
304:
305: You should also read Foundation technical note 16 (MFC\DOC\TN016.TXT)
306: for more information on MFC and multiple inheritance.
307:
308: -------------------------------------------------------------------------
309:
310: MULTIPAD\MULTIPAD.EXE
311:
312: Microsoft Windows provides a simple application called NOTEPAD. The
313: MFC library adaptation of this program uses the MDI paradigm to allow
314: the user to manipulate any number of concurrently open text files.
315: MULTIPAD is fully functional and includes printing support as well as
316: other features usually found only in commercial Windows applications:
317: a status bar at the bottom of the window, and a cache of
318: most-recently-used filenames (saved between program invocations) so
319: that users may quickly access recently used documents. The source
320: code illustrates the following concepts:
321:
322: - Non-trivial MDI application structuring.
323: - Menu command dispatching.
324: - Dialog box initialization and management.
325: - Printing.
326: - Porting existing Windows code for use with MFC.
327: - Swap tuning an application for Windows for maximum efficiency.
328:
329:
330: -------------------------------------------------------------------------
331:
332: OCLIENT\OCLIENT.EXE
333:
334: OCLIENT is an example of an Object Linking and Embedding (OLE) client
335: application. It uses the Foundation OLE classes. This program is a port
336: of the OLEDEMOC program which is shipped by the Microsoft OLE Software
337: Development Kit. The program allows you to insert both embedded and
338: linked objects into a document. OCLIENT also allows you to perform both
339: file and clipboard operations on the objects as well as activate the
340: servers to which the objects belong. The source code illustrates the
341: following concepts:
342:
343: - OLE client programming using MFC
344: - Inserting embedded objects into a client
345: - Pasting linked and embedded objects into a client
346: - Copying objects to the clipboard
347: - Loading and saving objects to and from disk
348:
349: It is highly recommended that you read Foundation technical notes 8, 9,
350: and 10 (MFC\DOC\TN008.TXT, etc.) for more information on the MFC OLE
351: classes and constructing OLE clients and servers using MFC.
352:
353: -------------------------------------------------------------------------
354:
355: OSERVER\BIBREF.EXE
356:
357: BIBREF is a simple OLE server application that implements
358: bibliographical references. When BIBREF is *directly* run, it
359: registers itself with the registraton database and allows you to add,
360: modify, and delete bibliographical references from a list maintained
361: by the application. YOU MUST RUN BIBREF DIRECTLY before using it
362: with other OLE programs. When run from an OLE client, BIBREF allows
363: you to embed objects containing these references in the client
364: application's document.
365:
366: The source code illustrates the following concepts:
367:
368: - Constructing an OLE server
369: - Programming with the MFC OLE classes
370: - Supporting embedded objects
371:
372: It is highly recommended that you read Foundation technical notes 8, 9,
373: and 10 (MFC\DOC\TN008.TXT, etc.) for more information on the MFC OLE
374: classes and constructing OLE clients and servers using MFC.
375:
376:
377: -------------------------------------------------------------------------
378:
379: SHOWFONT\SHOWFONT.EXE
380:
381: This program is a C++/Foundation adaptation of a sample application
382: provided in the Microsoft Windows 3.0 Software Development Kit (SDK).
383: SHOWFONT is a font attribute viewer. It allows you to quickly
384: determine the visual and logical characteristics of Windows GDI FONT
385: resources. The source code illustrates the following concepts:
386:
387: - Modal and modeless dialog box management.
388: - CFont attribute manipulation.
389: - Menu command dispatching.
390:
391:
392: -------------------------------------------------------------------------
393:
394: TEMPLDEF\TEMPLDEF.EXE
395:
396: TEMPLDEF is a non-Windows tool that helps you write and use
397: template-like classes. Templates are a proposed (but not established)
398: C++ language feature that are very useful for industrial-strength
399: programming. The MFC library's collection classes use template
400: classes (and the tool provided in this directory) to create specific
401: collection types from general collection types.
402:
403: The C++ language will someday support such features, but this tool
404: makes some of these proposed advantages available now. TEMPLDEF
405: reads a "template" file, and writes a new C++ class which is
406: type-safe.
407:
408: After you have built the templdef tool, you can use the MKCOLL.BAT
409: batch file and the array, list, and map template files (all in the
410: TEMPLDEF subdirectory) to generate your own versions of arrays,
411: lists, and maps.
412:
413: For more information on the templdef tool, see MFC Technical Note #4,
414: "Template Classes and AFX" (located in MFC\DOC\TN004.TXT). For more
415: information on proposed C++ templates, see Chapter 14 of "The Annotated
416: C++ Reference Manual," by Ellis and Stroustrup.
417:
418:
419:
420: -------------------------------------------------------------------------
421:
422: TRACER\TRACER.EXE
423:
424: TRACER is a tiny Windows utility that allows you to view and set the
425: Foundation Windows diagnostic trace option flags described in
426: MFC\DOC\TN007.TXT. The source code illustrates the following concepts:
427:
428: - Reading and writing Windows profile strings
429: - Writing a Foundation application that uses a modal dialog
430: box but does not use the regular Windows/MFC message pump.
431:
432:
433: -------------------------------------------------------------------------
434:
435: TUTORIAL\PHBOOK.EXE
436:
437: PHBOOK is a phone list maintenance application, and is the subject
438: of the MFC tutorial. PHBOOK allows you to create, edit, print and
439: save lists of people's names and their telephone numbers. In addition
440: to MFC application programming techniques, this application demonstrates
441: the development of an abstract data model and the coupling of that
442: data model to a graphical user interface implemented with MFC. See
443: TUTORIAL\README.TXT for more information on building this application.
444: The source code illustrates the following concepts:
445:
446: - MFC Application organization.
447: - Printing.
448: - Dialog box management.
449: - Coupling an abstract data model to a user interface.
450: - Using MFC object serialization (CArchive class) to save
451: and load user data.
452:
453: -------------------------------------------------------------------------
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.