Getting Started with Microsoft Visual C++ 6 with an Introduction to MFC / Edition 2

Paperback (Print)
Used and New from Other Sellers
Used and New from Other Sellers
from $58.21
Usually ships in 1-2 business days
Other sellers (Paperback)
  • All (7) from $58.21   
  • New (4) from $144.90   
  • Used (3) from $58.21   
Close
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any BN.com coupons and promotions
$144.90
Seller since 2008

Feedback rating:

(190)

Condition:

New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

New
0130132497 New. Looks like an interesting title!

Ships from: Naperville, IL

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
$174.50
Seller since 2014

Feedback rating:

(257)

Condition: New
Brand New Item.

Ships from: Chatham, NJ

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$175.00
Seller since 2014

Feedback rating:

(136)

Condition: New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
$175.00
Seller since 2014

Feedback rating:

(136)

Condition: New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
Page 1 of 1
Showing All
Close
Sort by

Overview

This companion to C++ How to Program: Second Edition—the world's most widely used university C++ textbook—carefully introduces how to use the Microsoft Visual Studio™ 6 integrated development environment (IDE) and Visual C++ 6 to create Windows® programs using basic Microsoft Foundation Classes (MFC).

Authors Harvey and Paul Deitel are the principals of Deitel & Associates, Inc., the internationally-recognized organization specializing in C++, Java™, C, Visual Basic®, object technology and Internet and World Wide Web programming training. The Deitels are also the authors of the best-selling textbooks, Java How to Program, C How to Program, C++ How to Program, Visual Basic 6 How to Program, and Internet and World Wide Web How to Program. The Deitels, Tem R. Nieto and Edward T. Strassberger introduce MFC programming fundamentals with Visual C++ 6.

Key topics include:

  • IDE, console applications, Win32® applications
  • Online documentation, Web resources
  • GUI controls (i.e., edit texts, list boxes, etc.)
  • Graphics, message handling
  • Debugger, dialog boxes
  • Resource definition language

Getting Started with Microsoft Visual C++ 6 with an Introduction to MFC includes:

  • 17 'live-code' Visual C++/MFC programs with screen captures
  • Exercises (many with answers) accompanying every chapter
  • Dozens of tips, recommended practices, and cautions-all marked with icons
    — Good Programming Practices
    —Software Engineering Observations
    —Performance Ties
    —Portability Tips
    —Look-and-Feel Observations
    —Testing and Debugging Tips
    —Common Programming Errors

This companion to C++ How to Program is part of a family of resources for teaching and learning C++, including a Web site (http://www.prenhall.com/deitel) with the book's code examples and other information for faculty, students and professionals; an optional interactive CD-ROM (C & C++ Multimedia Cyber Classroom) containing extensive interactivity features—such as thousands of hyperlinks and audio walkthroughs of the code examples in C++ How to Program—and e-mail access to the authors at
deitel@deitel.com

For information on corporate on-site seminars and public seminars offered by Deitel & Associates, Inc. worldwide see the last few pages of this book and/or visit:
http://www.deitel.com

For information on Visual C++ and MFC visit:
http://www.microsoft.com/visualc
http://www.codeguru.com

Read More Show Less

Product Details

  • ISBN-13: 9780130132499
  • Publisher: Prentice Hall
  • Publication date: 7/13/2002
  • Edition description: Subsequent
  • Edition number: 2
  • Pages: 163
  • Product dimensions: 7.00 (w) x 9.00 (h) x 0.70 (d)

Meet the Author

Harvey Deitel and Paul Deitel are principals of Deitel & Associates, Inc., a leader in programming training; and authors of C++ How to Program and Java How to Program — each the #1 book in its market. They have taught 500,000 programmers.

T.R. Nieto, an MIT graduate, is senior lecturer at Deitel & Associates.

Edward T. Strassberger is the owner of Strassberger Software Training, Inc.

Read More Show Less

Read an Excerpt

Welcome to Visual C++ and the exciting world of Microsoft Foundation Classes (MFC)! This book is by four guys—HMD (Massachusetts Institute of Technology 1967), PJD (MIT 1991), TRN (MIT 1992) and ETS (University of Maryland 1969) who have been programming and/or teaching for 38, 16, 16 and 36 years, respectively. We got together to produce a book we hope you will find a valuable supplement to our book, C++ How to Program: Second Edition (ISBN # 0-13-528910-6), and to its optional multimedia companion, The Complete C++ Training Course: Second Edition (ISBN #0-13916305-0).

Getting Started with Visual C++ 6 with an Introduction to MFC does not teach C++ programming. Rather it assumes that you know C++ or are learning it from any ANSI/ISO C++ textbook such as C++ How to Program: Second Edition.

This textbook is part of a package we designed in cooperation with Microsoft to help you start creating, editing, and evolving C++ applications in the Microsoft Visual C++ 6 integrated development environment (IDE). The source code for all the MFC program examples in this book can be downloaded from our website:
http://www.deitel.com

Click the Downloads link to access the source code for all our books.

The vast majority of programs in C++ How to Program: Second Edition successfully compile with the Microsoft Visual C++ 6.0 compiler. A listing of the few programs that do not compile properly, as well as appropriate fixes can be found on our web site at
http://www.deitel.com/products_and_services/publications/

Click the link on this page for Getting Started with Visual C++ 6with an Introduction to MFC.

For technical support with any of our CD-ROMs or interactive Multimedia Cyber Classrooms, please contact Prentice Hall at
tech_support@prenhall.com

They respond promptly during regular business hours (East Coast Time; United States). We will be happy to answer your programming language questions via email at
deitel@deitel.com

We hope you enjoy this book and programming in Microsoft's Visual C++ 6 integrated development environment with MFC! Why We Wrote Getting Started with Visual C++ 6.0 with an Introduction to MFC

C++ How To Program: Second Edition teaches ANSI/ISO C++ programming—an internationally used language that does not provide capabilities for creating graphical user interfaces (GUIs). Many of our readers have asked us to prepare a supplement that would introduce the fundamental concepts of Microsoft Windows programming (i.e., creating graphical user interfaces and writing graphics-intensive programs) using MFC. Our adopters asked us to use the same "live-code" approach (i.e., teaching each concept in the context of complete working example programs followed by the screen dialogs) that we employ in all our How to Program Series textbooks. Our goal was clear: produce a Visual C++ 6 book for introductory university-level C++ programming courses that would supplement C++ How to Program: Second Edition or any other ANSI/ISO C++ textbook, and would introduce fundamental MFC GUI-and-graphics programming concepts. Our Approach to Presenting MFC

The Microsoft Foundation Classes (MFC) library is a large collection of classes that help Visual C++ 6 programmers quickly create powerful Windows-based applications.

MFC programming is a substantial and complex topic. Various 1000-page MFC books are available for full-semester advanced programming courses. Our book is not intended as an alternative to these. Rather it is intended as a supplement to the introductory/intermediate-level programming courses typically taught from generic ANSI/ISO C++ textbooks like our C++ How to Program: Second Edition. Most colleges do not teach MFC programming in these courses. But several have told us that they would like to offer a brief introduction to Windows programming with MFC in their C++ courses. Chapter One of the book describes how to create and run MFC-based programs using Microsoft's Integrated Development Environment (IDE).

Visual C++ provides so-called wizards to generate a program's skeletal code or "boiler plate" code—the common code that a Windows program requires. The wizards generate this code and then mark the sections where programmers should fill in the code specific to their applications. Experienced programmers like wizards because they enable rapid application development. Editing the code generated by a wizard is not a task for beginning MFC programmers. This code is complex and requires a deep understanding of MFC.

We do not use wizards in this book. Our approach is to build the student's understanding of MFC fundamentals gradually by explaining small, narrowly-focused, complete examples. We feel that the student should first see and code small MFC programs to gain a solid understanding of MFC fundamentals. After studying this book, the student can then begin experimenting with wizards. Teaching Approach

Getting Started with Visual C++ 6 with an Introduction to MFC contains a rich collection of examples, exercises and projects drawn from many fields to provide the student with a chance to solve interesting real-world problems. The book concentrates on the principles of good software engineering and stresses program clarity. We avoid arcane terminology and syntax specifications in favor of teaching by example. Each of our code examples has been carefully tested. This book is written by four educators who spend most of their time teaching edge-of-the-practice topics in industry classrooms worldwide. The text emphasizes pedagogy.

Introducing Object Orientation from Chapter Two.
Getting Started with Visual C++ 6 with an Introduction to MFC "jumps right in" with object-oriented programming and even basic graphical user interface design from Chapter 2! MFC students really want to "cut to the chase." There is great stuff to be done in MFC so let's get right to it! MFC is not trivial by any means, but it's fun and students can see immediate results. Students can get graphical programs running quickly through MFC's extensive class libraries of "reusable components."

Live-Code Teaching Approach
The book is loaded with live-code examples. This is the focus of the way we teach and write about programming, and the focus of each of our multimedia Cyber Classrooms. Virtually every new concept is presented in the context of a complete, working MFC program immediately followed by one or more windows showing the program's output. We call this style of teaching and writing our live-code approach. We use the language to teach the language. Reading these programs is much like entering and running them on a computer.

World Wide Web Access
All of the code for Getting Started with Visual C++ 6 with an Introduction to MFC is on the Internet at the Prentice Hall Web site http://www.prenhall.com/deitel and at the Deitel & Associates, Inc. Web site http://www.deitel.com. Please download all the code then run each program as you read the text. Make changes to the code examples and see what happens. See how the Visual C++ 6 compiler "complains" when you make various kinds of errors. See the effects of making changes to the code. It's a great way to learn MFC programming by doing MFC programming. Please respect the fact that this is copyrighted material. Feel free to use it as you study MFC, but you may not republish any portion of it without explicit permission from the authors and Prentice Hall.

Objectives
Each chapter begins with a statement of Objectives. This tells the student what to expect and gives the student an opportunity, after reading the chapter, to determine if he or she has met these objectives. It is a confidence builder and a source of positive reinforcement.

Quotations
The learning objectives are followed by quotations. Some are humorous, some are philosophical and some offer interesting insights. Our students enjoy relating the quotations to the chapter material. The quotations are worth a "second look" after you read each chapter.

Outline
The chapter Outline helps the student approach the material in top-down fashion. This, too, helps students anticipate what is to come and set a comfortable and effective learning pace.

Approximately 1,708 lines of code in 17 Example Programs (with Program Outputs)
We present MFC features in the context of complete, working Visual C++ 6/MFC programs. This is the focus of our teaching and our writing. Each program is followed by a window with the output produced when the program runs. This enables the student to confirm that the programs run as expected. Reading the book carefully is much like entering and running these programs on a computer. The programs range from a few lines of code to substantial examples with many lines of code. Students should download all the code for the book from our Web sites (and run each program while studying that program in the text.

53 Illustrations/Figures
An abundance of charts, line drawings and program outputs is included.

40 Programming Tips
We have included programming tips to help students focus on important aspects of program development. We highlight dozens of these tips in the form of Good Programming Practices, Common Programming Errors, Testing and Debugging Tips, Look-and-Feel Observations, Portability Tips, and Software Engineering Observations. These tips and practices represent the best we have been able to glean from a combined ten decades of programming and teaching experience. One of our students—a mathematics major—told us recently that she feels this approach is like the highlighting of axioms, theorems and corollaries in mathematics books; it provides a basis on which to build good software.

6 Good Programming Practices
When we teach introductory courses, we state that the "buzzword" of each course is "clarity," and we highlight as Good Programming Practices techniques for writing programs that are clearer, more understandable, more debuggable, and more maintainable.

7 Common Programming Errors
Students learning a language tend to make certain errors frequently. Focusing the students' attention on these Common Programming Errors helps students avoid making the same errors. It also helps reduce the long lines outside instructors' offices during office hours!

11 Testing and Debugging Tips
These tips will help you determine if your program is running correctly and, if not, quickly locate and remove any bugs.

4 Look-and-Feel Observations
We provide Look-and-Feel Observations to highlight Windows graphical user interface conventions. These observations help students design their applications to "look" and "feel" like typical Windows programs.

1 Portability Tip
We include a Portability Tip to help students write code that will port easily among a variety of MFC-based platforms.

11 Software Engineering Observations
The object-oriented programming paradigm requires a complete rethinking about the way we build software systems. MFC is effective for performing good software engineering. The Software Engineering Observations highlight architectural and design issues that affect the construction of software systems, especially large-scale systems. Much of what the student learns here will be useful in upper-level courses and in industry as the student begins to work with large, complex real-world systems.

Summary
Each chapter ends with additional pedagogical devices. We present a thorough, bullet-list-style Summary of the chapter. On average, there are 29 summary bullets per chapter. This helps the students review and reinforce key concepts.

Terminology
We include in a Terminology section an alphabetized list of the important terms defined in the chapter—again, further reinforcement. On average, there are 85 terms per chapter.

Summary of Tips, Practices, and Errors
For ease of reference, we collect and reiterate the Good Programming Practices, Common Programming Errors, Testing and Debugging Tips, Look-and-Feel Observations, Portability Tips and Software Engineering Observations.

55 Self-Review Exercises and Answers (Count Includes Separate Parts)
Extensive self-review exercises and answers are included for self-study. This gives the student a chance to build confidence with the material and prepare for the regular exercises. Students should be encouraged to do all the self-review exercises and check their answers.

49 Exercises (Count Includes Separate Parts)
Each chapter concludes with a substantial set of exercises including simple recall of important terminology and concepts; writing individual MFC statements; writing small portions of functions and classes; writing complete MFC functions, classes and applications; and writing major term projects. The variety of exercises enables instructors to tailor their courses to the unique needs of their audiences and to vary course assignments each semester. Instructors can use these exercises to form homework assignments, short quizzes, and major examinations. NOTE: Please do not write to us requesting the solutions to the exercises. Distribution of the solutions is strictly limited to college professors teaching from the book. Instructors may obtain the solutions only from their regular Prentice Hall representatives.

Approximately 1129 Index Entries (with approximately 1942 Page References)
We have included an extensive Index at the back of the book. This helps the student find any term or concept by keyword. The Index is useful to people reading the book for the first time and is especially useful to practicing programmers who use the book as a reference. Each of the 437 terms in the Terminology sections appears in the Index (along with many more index items from each chapter). Students can use the Index in conjunction with the Terminology sections to be sure they have covered the key material of each chapter.

Bibliography
An extensive bibliography is included to encourage further reading. A Tour of the Book

This book contains five chapters, an Internet and World Wide Web resource appendix, and a bibliography. Each chapter contains examples that carefully illustrate Visual C++ and MFC concepts. Each chapter concludes with a summary, a terminology list, a list of programming tips, self-review exercises (with answers) and exercises (without answers).

Chapter 1: Visual C++ Integrated Development Environment introduces the basics of the Microsoft Visual Studio 6 integrated development environment (IDE); discusses the online documentation; explains how to create, save and execute a Windows console application (i.e., an application that does not use graphical user interface elements such as windows and buttons) and discusses the debugger. Helpful integrated development environment features such as syntax color highlighting—the coloring of keywords, comments and values for emphasis—are discussed. This chapter introduces the concept of a project-a group of program files associated with an application that resides in a specific directory. All programs compiled in Visual C++ use projects.

The debugger helps programmers find code that, although it does not violate C++ syntax, contains logic errors (e.g., infinite loops, division-by-zero exceptions, off-by-one errors, etc.) that prevent the program from executing correctly. The debug toolbar and menu contain the tools necessary to debug a C++ application. Capabilities such as watching variable values change as a program executes are discussed. Chapter 1 is designed to be taught as early as possible in your curriculum to allow students to develop programs using the Visual C++ IDE. Note: The debugger section references functions and should therefore be taught after Chapter 3 "Functions" in C++ How to Program: Second Edition.

Chapter 2: MFC Programming: Part I introduces Windows programming (i.e., creating programs that have GUIs) with MFC and event-driven programming—writing code that responds to user interactions with programs (such as button clicks). Each "live-code" example presents one or two new concepts in a short, concise fashion. Each example includes screen captures showing the user's interaction with the program at execution time.

In this chapter we overview some of the classes in the MFC hierarchy. We outline the subset of MFC classes we present in this introductory book. We also provide a "high-level" discussion of MFC events—called messages—that describes the code needed for event-driven programming. We introduce the Hungarian notation convention for naming identifiers used in Microsoft's MFC documentation and widely practiced in the MFC programming community. We also list (step-by-step) how to create a project for a Windows application with a graphical user interface (i.e., a Visual C++ program that uses MFC).

The first program is our classic "Welcome to" program. It introduces the minimal code needed to implement an MFC application. The second example demonstrates how to create menus. The program creates a series of menus containing food-related items. When a food-item is selected, its price is added to a running total. This example introduces message handling and a message box window for displaying text to the user. The last "live-code" example introduces the edit text control (i.e., a control for accepting input), buttons and dialog-based applications.

Because MFC is a class hierarchy it uses inheritance. Chapters 2 through 5 should be taught after Chapter 9 "Inheritance" in C++ How to Program: Second Edition.

Chapter 3: MFC Programming: Part II continues the Windows programming discussion started in Chapter 2. This chapter contains 4 "live-code" examples. The first example demonstrates password protection for edit text controls by masking input with asterisks. In this example, we also enhance message box windows by adding predefined icons. The second example demonstrates how to handle mouse messages. In this example, we demonstrate how to code mouse handlers to determine the coordinates of a mouse click and to determine which mouse button was clicked. This example also introduces basic graphics by drawing directly on the window. The third "live-code" example demonstrates how to code key handlers (i.e., handlers that execute when a key on the keyboard is pressed). In this example, we create a simple text editor. The last example builds upon the graphics techniques introduced earlier in the chapter by drawing centered-red text in the window.

Chapter 4: Graphical User Interface Controls presents 5 MFC controls for enhancing GUIs. We carefully selected these controls based upon our experience with GUI design using Visual J++ and Visual Basic. The set of controls we present is fundamental to Windows programming.

The first "live-code" example demonstrates how to create and use a multiline edit text control. This example allows the user to type text into a multiline edit control as if it were a simple text editor. The second example demonstrates toggle controls called check boxes. A control—called a group box—for grouping other controls is also introduced. The third "live-code" example introduces mutually-exclusive toggle controls called radio buttons. This example demonstrates how radio buttons are combined into groups and how they differ from check boxes. The last two examples demonstrate controls (list boxes and combo boxes) that provide a lists of strings. We discuss how to add strings to these controls and how to remove strings from these controls.

Chapter 5: Graphics. We thought you might enjoy an introductory chapter on graphics, so we went one step further in this book than just introducing GUI programming. Unfortunately, graphics are not included as part of ANSI/ISO C++, so graphics may be a new topic to many C++ programmers. MFC provides a rich collection of classes and functions for creating and manipulating graphics. As with the previous chapters, we have carefully selected introductory MFC features that are demonstrated using five "live-code" examples.

We present the topic of colors that allow graphics to "come-alive" by discussing the RGB (red, green and blue) values that form a color. We provide a list of RGB values for common colors in a table.

The first "live-code" example draws a rectangle and a solid-red ellipse in a window. The program demonstrates how to create brushes (objects that specify color and fill patterns of an enclosed area) and pens (objects that specify line color, thickness and pattern).

The second "live-code" example builds upon the first example by introducing additional brush and pen features and by introducing functions for drawing lines and polygons. This example draws a rectangle and a solid-green arrow in a window.

Our third "live-code" example introduces the timer object which sends a message to a message handler after a specified number of milliseconds has elapsed. Timers have numerous applications, especially in graphics where shapes can be drawn at different coordinates when the timer message is received—creating a simple animation. In this example, we animate the colors inside a rectangle by manipulating each individual pixel's color.

The fourth "live-code" example demonstrates how a bitmap image can be displayed in a window and the fifth example introduces fonts. We discuss how to manipulate the font name, size and weight. Font manipulation is important for emphasizing and de-emphasizing text.

Appendix A: Resources and Demos lists some popular sites on the World Wide Web pertaining to Visual C++ and MFC. A Bibliography is included to encourage further reading.

Read More Show Less

Table of Contents

1. Visual Studio 6 Integrated Development Environment.

Introduction. Integrated Development Environment Overview: Visual C++. Online Visual C++ Documentation. Creating and Executing a C++ Application. Debugger.

2. MFC Programming: Part 1.

Introduction. MFC Classes. Messages. MFC Resources. Hungarian Notation. Win32 Application Projects. Creating Simple C++ with MFC. Menus. Dialog Boxes.

3. MFC Programming: Part 2.

Introduction. Password Protection. Processing Mouse Messages. Processing Keyboard Input Messages. Text Output.

4. MFC Graphical User Interface Controls.

Introduction. Multiline Edit Text Control. Check Boxes. Radio Button. List Boxes. Combo Boxes.

5. MFC Graphics.

Introduction. Coordinate Systems. Colors. Drawing Functions. Drawing Properties. Shapes and Lines. Timers. Images. Fonts. Closing Remarks.

Appendix: MFC Resources.

Introduction. Resources. Tutorials. FAQs. Products. Newsletters and Publications. Newsgroups.

Bibliography.

Read More Show Less

Preface

Welcome to Visual C++ and the exciting world of Microsoft Foundation Classes (MFC)! This book is by four guys—HMD (Massachusetts Institute of Technology 1967), PJD (MIT 1991), TRN (MIT 1992) and ETS (University of Maryland 1969) who have been programming and/or teaching for 38, 16, 16 and 36 years, respectively. We got together to produce a book we hope you will find a valuable supplement to our book, C++ How to Program: Second Edition (ISBN # 0-13-528910-6), and to its optional multimedia companion, The Complete C++ Training Course: Second Edition (ISBN #0-13916305-0).

Getting Started with Visual C++ 6 with an Introduction to MFC does not teach C++ programming. Rather it assumes that you know C++ or are learning it from any ANSI/ISO C++ textbook such as C++ How to Program: Second Edition.

This textbook is part of a package we designed in cooperation with Microsoft to help you start creating, editing, and evolving C++ applications in the Microsoft Visual C++ 6 integrated development environment (IDE). The source code for all the MFC program examples in this book can be downloaded from our website:
http://www.deitel.com

Click the Downloads link to access the source code for all our books.

The vast majority of programs in C++ How to Program: Second Edition successfully compile with the Microsoft Visual C++ 6.0 compiler. A listing of the few programs that do not compile properly, as well as appropriate fixes can be found on our web site at
http://www.deitel.com/products_and_services/publications/

Click the link on this page for Getting Started with Visual C++ 6 with an Introduction to MFC.

For technical support with any of our CD-ROMs or interactive Multimedia Cyber Classrooms, please contact Prentice Hall at
tech_support@prenhall.com

They respond promptly during regular business hours (East Coast Time; United States). We will be happy to answer your programming language questions via email at
deitel@deitel.com

We hope you enjoy this book and programming in Microsoft's Visual C++ 6 integrated development environment with MFC!

Why We Wrote Getting Started with Visual C++ 6.0 with an Introduction to MFC

C++ How To Program: Second Edition teaches ANSI/ISO C++ programming—an internationally used language that does not provide capabilities for creating graphical user interfaces (GUIs). Many of our readers have asked us to prepare a supplement that would introduce the fundamental concepts of Microsoft Windows programming (i.e., creating graphical user interfaces and writing graphics-intensive programs) using MFC. Our adopters asked us to use the same "live-code" approach (i.e., teaching each concept in the context of complete working example programs followed by the screen dialogs) that we employ in all our How to Program Series textbooks. Our goal was clear: produce a Visual C++ 6 book for introductory university-level C++ programming courses that would supplement C++ How to Program: Second Edition or any other ANSI/ISO C++ textbook, and would introduce fundamental MFC GUI-and-graphics programming concepts.

Our Approach to Presenting MFC

The Microsoft Foundation Classes (MFC) library is a large collection of classes that help Visual C++ 6 programmers quickly create powerful Windows-based applications.

MFC programming is a substantial and complex topic. Various 1000-page MFC books are available for full-semester advanced programming courses. Our book is not intended as an alternative to these. Rather it is intended as a supplement to the introductory/intermediate-level programming courses typically taught from generic ANSI/ISO C++ textbooks like our C++ How to Program: Second Edition. Most colleges do not teach MFC programming in these courses. But several have told us that they would like to offer a brief introduction to Windows programming with MFC in their C++ courses. Chapter One of the book describes how to create and run MFC-based programs using Microsoft's Integrated Development Environment (IDE).

Visual C++ provides so-called wizards to generate a program's skeletal code or "boiler plate" code—the common code that a Windows program requires. The wizards generate this code and then mark the sections where programmers should fill in the code specific to their applications. Experienced programmers like wizards because they enable rapid application development. Editing the code generated by a wizard is not a task for beginning MFC programmers. This code is complex and requires a deep understanding of MFC.

We do not use wizards in this book. Our approach is to build the student's understanding of MFC fundamentals gradually by explaining small, narrowly-focused, complete examples. We feel that the student should first see and code small MFC programs to gain a solid understanding of MFC fundamentals. After studying this book, the student can then begin experimenting with wizards.

Teaching Approach

Getting Started with Visual C++ 6 with an Introduction to MFC contains a rich collection of examples, exercises and projects drawn from many fields to provide the student with a chance to solve interesting real-world problems. The book concentrates on the principles of good software engineering and stresses program clarity. We avoid arcane terminology and syntax specifications in favor of teaching by example. Each of our code examples has been carefully tested. This book is written by four educators who spend most of their time teaching edge-of-the-practice topics in industry classrooms worldwide. The text emphasizes pedagogy.

Introducing Object Orientation from Chapter Two.
Getting Started with Visual C++ 6 with an Introduction to MFC "jumps right in" with object-oriented programming and even basic graphical user interface design from Chapter 2! MFC students really want to "cut to the chase." There is great stuff to be done in MFC so let's get right to it! MFC is not trivial by any means, but it's fun and students can see immediate results. Students can get graphical programs running quickly through MFC's extensive class libraries of "reusable components."

Live-Code Teaching Approach
The book is loaded with live-code examples. This is the focus of the way we teach and write about programming, and the focus of each of our multimedia Cyber Classrooms. Virtually every new concept is presented in the context of a complete, working MFC program immediately followed by one or more windows showing the program's output. We call this style of teaching and writing our live-code approach. We use the language to teach the language. Reading these programs is much like entering and running them on a computer.

World Wide Web Access
All of the code for Getting Started with Visual C++ 6 with an Introduction to MFC is on the Internet at the Prentice Hall Web site http://www.prenhall.com/deitel and at the Deitel & Associates, Inc. Web site http://www.deitel.com. Please download all the code then run each program as you read the text. Make changes to the code examples and see what happens. See how the Visual C++ 6 compiler "complains" when you make various kinds of errors. See the effects of making changes to the code. It's a great way to learn MFC programming by doing MFC programming. Please respect the fact that this is copyrighted material. Feel free to use it as you study MFC, but you may not republish any portion of it without explicit permission from the authors and Prentice Hall.

Objectives
Each chapter begins with a statement of Objectives. This tells the student what to expect and gives the student an opportunity, after reading the chapter, to determine if he or she has met these objectives. It is a confidence builder and a source of positive reinforcement.

Quotations
The learning objectives are followed by quotations. Some are humorous, some are philosophical and some offer interesting insights. Our students enjoy relating the quotations to the chapter material. The quotations are worth a "second look" after you read each chapter.

Outline
The chapter Outline helps the student approach the material in top-down fashion. This, too, helps students anticipate what is to come and set a comfortable and effective learning pace.

Approximately 1,708 lines of code in 17 Example Programs (with Program Outputs)
We present MFC features in the context of complete, working Visual C++ 6/MFC programs. This is the focus of our teaching and our writing. Each program is followed by a window with the output produced when the program runs. This enables the student to confirm that the programs run as expected. Reading the book carefully is much like entering and running these programs on a computer. The programs range from a few lines of code to substantial examples with many lines of code. Students should download all the code for the book from our Web sites (and run each program while studying that program in the text.

53 Illustrations/Figures
An abundance of charts, line drawings and program outputs is included.

40 Programming Tips
We have included programming tips to help students focus on important aspects of program development. We highlight dozens of these tips in the form of Good Programming Practices, Common Programming Errors, Testing and Debugging Tips, Look-and-Feel Observations, Portability Tips, and Software Engineering Observations. These tips and practices represent the best we have been able to glean from a combined ten decades of programming and teaching experience. One of our students—a mathematics major—told us recently that she feels this approach is like the highlighting of axioms, theorems and corollaries in mathematics books; it provides a basis on which to build good software.

6 Good Programming Practices
When we teach introductory courses, we state that the "buzzword" of each course is "clarity," and we highlight as Good Programming Practices techniques for writing programs that are clearer, more understandable, more debuggable, and more maintainable.

7 Common Programming Errors
Students learning a language tend to make certain errors frequently. Focusing the students' attention on these Common Programming Errors helps students avoid making the same errors. It also helps reduce the long lines outside instructors' offices during office hours!

11 Testing and Debugging Tips
These tips will help you determine if your program is running correctly and, if not, quickly locate and remove any bugs.

4 Look-and-Feel Observations
We provide Look-and-Feel Observations to highlight Windows graphical user interface conventions. These observations help students design their applications to "look" and "feel" like typical Windows programs.

1 Portability Tip
We include a Portability Tip to help students write code that will port easily among a variety of MFC-based platforms.

11 Software Engineering Observations
The object-oriented programming paradigm requires a complete rethinking about the way we build software systems. MFC is effective for performing good software engineering. The Software Engineering Observations highlight architectural and design issues that affect the construction of software systems, especially large-scale systems. Much of what the student learns here will be useful in upper-level courses and in industry as the student begins to work with large, complex real-world systems.

Summary
Each chapter ends with additional pedagogical devices. We present a thorough, bullet-list-style Summary of the chapter. On average, there are 29 summary bullets per chapter. This helps the students review and reinforce key concepts.

Terminology
We include in a Terminology section an alphabetized list of the important terms defined in the chapter—again, further reinforcement. On average, there are 85 terms per chapter.

Summary of Tips, Practices, and Errors
For ease of reference, we collect and reiterate the Good Programming Practices, Common Programming Errors, Testing and Debugging Tips, Look-and-Feel Observations, Portability Tips and Software Engineering Observations.

55 Self-Review Exercises and Answers (Count Includes Separate Parts)
Extensive self-review exercises and answers are included for self-study. This gives the student a chance to build confidence with the material and prepare for the regular exercises. Students should be encouraged to do all the self-review exercises and check their answers.

49 Exercises (Count Includes Separate Parts)
Each chapter concludes with a substantial set of exercises including simple recall of important terminology and concepts; writing individual MFC statements; writing small portions of functions and classes; writing complete MFC functions, classes and applications; and writing major term projects. The variety of exercises enables instructors to tailor their courses to the unique needs of their audiences and to vary course assignments each semester. Instructors can use these exercises to form homework assignments, short quizzes, and major examinations. NOTE: Please do not write to us requesting the solutions to the exercises. Distribution of the solutions is strictly limited to college professors teaching from the book. Instructors may obtain the solutions only from their regular Prentice Hall representatives.

Approximately 1129 Index Entries (with approximately 1942 Page References)
We have included an extensive Index at the back of the book. This helps the student find any term or concept by keyword. The Index is useful to people reading the book for the first time and is especially useful to practicing programmers who use the book as a reference. Each of the 437 terms in the Terminology sections appears in the Index (along with many more index items from each chapter). Students can use the Index in conjunction with the Terminology sections to be sure they have covered the key material of each chapter.

Bibliography
An extensive bibliography is included to encourage further reading.

A Tour of the Book

This book contains five chapters, an Internet and World Wide Web resource appendix, and a bibliography. Each chapter contains examples that carefully illustrate Visual C++ and MFC concepts. Each chapter concludes with a summary, a terminology list, a list of programming tips, self-review exercises (with answers) and exercises (without answers).

Chapter 1: Visual C++ Integrated Development Environment introduces the basics of the Microsoft Visual Studio 6 integrated development environment (IDE); discusses the online documentation; explains how to create, save and execute a Windows console application (i.e., an application that does not use graphical user interface elements such as windows and buttons) and discusses the debugger. Helpful integrated development environment features such as syntax color highlighting—the coloring of keywords, comments and values for emphasis—are discussed. This chapter introduces the concept of a project-a group of program files associated with an application that resides in a specific directory. All programs compiled in Visual C++ use projects.

The debugger helps programmers find code that, although it does not violate C++ syntax, contains logic errors (e.g., infinite loops, division-by-zero exceptions, off-by-one errors, etc.) that prevent the program from executing correctly. The debug toolbar and menu contain the tools necessary to debug a C++ application. Capabilities such as watching variable values change as a program executes are discussed. Chapter 1 is designed to be taught as early as possible in your curriculum to allow students to develop programs using the Visual C++ IDE. Note: The debugger section references functions and should therefore be taught after Chapter 3 "Functions" in C++ How to Program: Second Edition.

Chapter 2: MFC Programming: Part I introduces Windows programming (i.e., creating programs that have GUIs) with MFC and event-driven programming—writing code that responds to user interactions with programs (such as button clicks). Each "live-code" example presents one or two new concepts in a short, concise fashion. Each example includes screen captures showing the user's interaction with the program at execution time.

In this chapter we overview some of the classes in the MFC hierarchy. We outline the subset of MFC classes we present in this introductory book. We also provide a "high-level" discussion of MFC events—called messages—that describes the code needed for event-driven programming. We introduce the Hungarian notation convention for naming identifiers used in Microsoft's MFC documentation and widely practiced in the MFC programming community. We also list (step-by-step) how to create a project for a Windows application with a graphical user interface (i.e., a Visual C++ program that uses MFC).

The first program is our classic "Welcome to" program. It introduces the minimal code needed to implement an MFC application. The second example demonstrates how to create menus. The program creates a series of menus containing food-related items. When a food-item is selected, its price is added to a running total. This example introduces message handling and a message box window for displaying text to the user. The last "live-code" example introduces the edit text control (i.e., a control for accepting input), buttons and dialog-based applications.

Because MFC is a class hierarchy it uses inheritance. Chapters 2 through 5 should be taught after Chapter 9 "Inheritance" in C++ How to Program: Second Edition.

Chapter 3: MFC Programming: Part II continues the Windows programming discussion started in Chapter 2. This chapter contains 4 "live-code" examples. The first example demonstrates password protection for edit text controls by masking input with asterisks. In this example, we also enhance message box windows by adding predefined icons. The second example demonstrates how to handle mouse messages. In this example, we demonstrate how to code mouse handlers to determine the coordinates of a mouse click and to determine which mouse button was clicked. This example also introduces basic graphics by drawing directly on the window. The third "live-code" example demonstrates how to code key handlers (i.e., handlers that execute when a key on the keyboard is pressed). In this example, we create a simple text editor. The last example builds upon the graphics techniques introduced earlier in the chapter by drawing centered-red text in the window.

Chapter 4: Graphical User Interface Controls presents 5 MFC controls for enhancing GUIs. We carefully selected these controls based upon our experience with GUI design using Visual J++ and Visual Basic. The set of controls we present is fundamental to Windows programming.

The first "live-code" example demonstrates how to create and use a multiline edit text control. This example allows the user to type text into a multiline edit control as if it were a simple text editor. The second example demonstrates toggle controls called check boxes. A control—called a group box—for grouping other controls is also introduced. The third "live-code" example introduces mutually-exclusive toggle controls called radio buttons. This example demonstrates how radio buttons are combined into groups and how they differ from check boxes. The last two examples demonstrate controls (list boxes and combo boxes) that provide a lists of strings. We discuss how to add strings to these controls and how to remove strings from these controls.

Chapter 5: Graphics. We thought you might enjoy an introductory chapter on graphics, so we went one step further in this book than just introducing GUI programming. Unfortunately, graphics are not included as part of ANSI/ISO C++, so graphics may be a new topic to many C++ programmers. MFC provides a rich collection of classes and functions for creating and manipulating graphics. As with the previous chapters, we have carefully selected introductory MFC features that are demonstrated using five "live-code" examples.

We present the topic of colors that allow graphics to "come-alive" by discussing the RGB (red, green and blue) values that form a color. We provide a list of RGB values for common colors in a table.

The first "live-code" example draws a rectangle and a solid-red ellipse in a window. The program demonstrates how to create brushes (objects that specify color and fill patterns of an enclosed area) and pens (objects that specify line color, thickness and pattern).

The second "live-code" example builds upon the first example by introducing additional brush and pen features and by introducing functions for drawing lines and polygons. This example draws a rectangle and a solid-green arrow in a window.

Our third "live-code" example introduces the timer object which sends a message to a message handler after a specified number of milliseconds has elapsed. Timers have numerous applications, especially in graphics where shapes can be drawn at different coordinates when the timer message is received—creating a simple animation. In this example, we animate the colors inside a rectangle by manipulating each individual pixel's color.

The fourth "live-code" example demonstrates how a bitmap image can be displayed in a window and the fifth example introduces fonts. We discuss how to manipulate the font name, size and weight. Font manipulation is important for emphasizing and de-emphasizing text.

Appendix A: Resources and Demos lists some popular sites on the World Wide Web pertaining to Visual C++ and MFC. A Bibliography is included to encourage further reading.

Read More Show Less

Introduction

Welcome to Visual C++ and the exciting world of Microsoft Foundation Classes (MFC)! This book is by four guys--HMD (Massachusetts Institute of Technology 1967), PJD (MIT 1991), TRN (MIT 1992) and ETS (University of Maryland 1969) who have been programming and/or teaching for 38, 16, 16 and 36 years, respectively. We got together to produce a book we hope you will find a valuable supplement to our book, C++ How to Program: Second Edition (ISBN # 0-13-528910-6), and to its optional multimedia companion, The Complete C++ Training Course: Second Edition (ISBN #0-13916305-0).

Getting Started with Visual C++ 6 with an Introduction to MFC does not teach C++ programming. Rather it assumes that you know C++ or are learning it from any ANSI/ISO C++ textbook such as C++ How to Program: Second Edition.

This textbook is part of a package we designed in cooperation with Microsoft to help you start creating, editing, and evolving C++ applications in the Microsoft Visual C++ 6 integrated development environment (IDE). The source code for all the MFC program examples in this book can be downloaded from our website.

Click the Downloads link to access the source code for all our books.

The vast majority of programs in C++ How to Program: Second Edition successfully compile with the Microsoft Visual C++ 6.0 compiler. A listing of the few programs that do not compile properly, as well as appropriate fixes can be found on our web site.

Click the link on this page for Getting Started with Visual C++ 6 with an Introduction to MFC.

For technical support with any of our CD-ROMs or interactive Multimedia CyberClassrooms, please contact Prentice Hall.

They respond promptly during regular business hours (East Coast Time; United States). We will be happy to answer your programming language questions via email.

We hope you enjoy this book and programming in Microsoft's Visual C++ 6 integrated development environment with MFC!

Why We Wrote Getting Started with Visual C++ 6.0 with an Introduction to MFC

C++ How To Program: Second Edition teaches ANSI/ISO C++ programming--an internationally used language that does not provide capabilities for creating graphical user interfaces (GUIs). Many of our readers have asked us to prepare a supplement that would introduce the fundamental concepts of Microsoft Windows programming (i.e., creating graphical user interfaces and writing graphics-intensive programs) using MFC. Our adopters asked us to use the same "live-code" approach (i.e., teaching each concept in the context of complete working example programs followed by the screen dialogs) that we employ in all our How to Program Series textbooks. Our goal was clear: produce a Visual C++ 6 book for introductory university-level C++ programming courses that would supplement C++ How to Program: Second Edition or any other ANSI/ISO C++ textbook, and would introduce fundamental MFC GUI-and-graphics programming concepts.

Our Approach to Presenting MFC

The Microsoft Foundation Classes (MFC) library is a large collection of classes that help Visual C++ 6 programmers quickly create powerful Windows-based applications.

MFC programming is a substantial and complex topic. Various 1000-page MFC books are available for full-semester advanced programming courses. Our book is not intended as an alternative to these. Rather it is intended as a supplement to the introductory/intermediate-level programming courses typically taught from generic ANSI/ISO C++ textbooks like our C++ How to Program: Second Edition. Most colleges do not teach MFC programming in these courses. But several have told us that they would like to offer a brief introduction to Windows programming with MFC in their C++ courses. Chapter One of the book describes how to create and run MFC-based programs using Microsoft's Integrated Development Environment (IDE).

Visual C++ provides so-called wizards to generate a program's skeletal code or "boiler plate" code--the common code that a Windows program requires. The wizards generate this code and then mark the sections where programmers should fill in the code specific to their applications. Experienced programmers like wizards because they enable rapid application development. Editing the code generated by a wizard is not a task for beginning MFC programmers. This code is complex and requires a deep understanding of MFC.

We do not use wizards in this book. Our approach is to build the student's understanding of MFC fundamentals gradually by explaining small, narrowly-focused, complete examples. We feel that the student should first see and code small MFC programs to gain a solid understanding of MFC fundamentals. After studying this book, the student can then begin experimenting with wizards.

Teaching Approach

Getting Started with Visual C++ 6 with an Introduction to MFC contains a rich collection of examples, exercises and projects drawn from many fields to provide the student with a chance to solve interesting real-world problems. The book concentrates on the principles of good software engineering and stresses program clarity. We avoid arcane terminology and syntax specifications in favor of teaching by example. Each of our code examples has been carefully tested. This book is written by four educators who spend most of their time teaching edge-of-the-practice topics in industry classrooms worldwide. The text emphasizes pedagogy.

Introducing Object Orientation from Chapter Two.
Getting Started with Visual C++ 6 with an Introduction to MFC "jumps right in" with object-oriented programming and even basic graphical user interface design from Chapter 2! MFC students really want to "cut to the chase." There is great stuff to be done in MFC so let's get right to it! MFC is not trivial by any means, but it's fun and students can see immediate results. Students can get graphical programs running quickly through MFC's extensive class libraries of "reusable components."

Live-Code Teaching Approach
The book is loaded with live-code examples. This is the focus of the way we teach and write about programming, and the focus of each of our multimedia Cyber Classrooms. Virtually every new concept is presented in the context of a complete, working MFC program immediately followed by one or more windows showing the program's output. We call this style of teaching and writing our live-code approach. We use the language to teach the language. Reading these programs is much like entering and running them on a computer.

World Wide Web Access
All of the code for Getting Started with Visual C++ 6 with an Introduction to MFC is on the Internet at the Prentice Hall Web site and at the Deitel & Associates, Inc. Web site. Please download all the code then run each program as you read the text. Make changes to the code examples and see what happens. See how the Visual C++ 6 compiler "complains" when you make various kinds of errors. See the effects of making changes to the code. It's a great way to learn MFC programming by doing MFC programming. Please respect the fact that this is copyrighted material. Feel free to use it as you study MFC, but you may not republish any portion of it without explicit permission from the authors and Prentice Hall.

Objectives
Each chapter begins with a statement of Objectives. This tells the student what to expect and gives the student an opportunity, after reading the chapter, to determine if he or she has met these objectives. It is a confidence builder and a source of positive reinforcement.

Quotations
The learning objectives are followed by quotations. Some are humorous, some are philosophical and some offer interesting insights. Our students enjoy relating the quotations to the chapter material. The quotations are worth a "second look" after you read each chapter.

Outline
The chapter Outline helps the student approach the material in top-down fashion. This, too, helps students anticipate what is to come and set a comfortable and effective learning pace.

Approximately 1,708 lines of code in 17 Example Programs (with Program Outputs)
We present MFC features in the context of complete, working Visual C++ 6/MFC programs. This is the focus of our teaching and our writing. Each program is followed by a window with the output produced when the program runs. This enables the student to confirm that the programs run as expected. Reading the book carefully is much like entering and running these programs on a computer. The programs range from a few lines of code to substantial examples with many lines of code. Students should download all the code for the book from our Web sites (and run each program while studying that program in the text.

53 Illustrations/Figures
An abundance of charts, line drawings and program outputs is included.

40 Programming Tips
We have included programming tips to help students focus on important aspects of program development. We highlight dozens of these tips in the form of Good Programming Practices, Common Programming Errors, Testing and Debugging Tips, Look-and-Feel Observations, Portability Tips, and Software Engineering Observations. These tips and practices represent the best we have been able to glean from a combined ten decades of programming and teaching experience. One of our students--a mathematics major--told us recently that she feels this approach is like the highlighting of axioms, theorems and corollaries in mathematics books; it provides a basis on which to build good software.

6 Good Programming Practices
When we teach introductory courses, we state that the "buzzword" of each course is "clarity," and we highlight as Good Programming Practices techniques for writing programs that are clearer, more understandable, more debuggable, and more maintainable.

7 Common Programming Errors
Students learning a language tend to make certain errors frequently. Focusing the students' attention on these Common Programming Errors helps students avoid making the same errors. It also helps reduce the long lines outside instructors' offices during office hours!

11 Testing and Debugging Tips
These tips will help you determine if your program is running correctly and, if not, quickly locate and remove any bugs.

4 Look-and-Feel Observations
We provide Look-and-Feel Observations to highlight Windows graphical user interface conventions. These observations help students design their applications to "look" and "feel" like typical Windows programs.

1 Portability Tip
We include a Portability Tip to help students write code that will port easily among a variety of MFC-based platforms.

11 Software Engineering Observations
The object-oriented programming paradigm requires a complete rethinking about the way we build software systems. MFC is effective for performing good software engineering. The Software Engineering Observations highlight architectural and design issues that affect the construction of software systems, especially large-scale systems. Much of what the student learns here will be useful in upper-level courses and in industry as the student begins to work with large, complex real-world systems.

Summary
Each chapter ends with additional pedagogical devices. We present a thorough, bullet-list-style Summary of the chapter. On average, there are 29 summary bullets per chapter. This helps the students review and reinforce key concepts.

Terminology
We include in a Terminology section an alphabetized list of the important terms defined in the chapter--again, further reinforcement. On average, there are 85 terms per chapter.

Summary of Tips, Practices, and Errors
For ease of reference, we collect and reiterate the Good Programming Practices, Common Programming Errors, Testing and Debugging Tips, Look-and-Feel Observations, Portability Tips and Software Engineering Observations.

55 Self-Review Exercises and Answers (Count Includes Separate Parts)
Extensive self-review exercises and answers are included for self-study. This gives the student a chance to build confidence with the material and prepare for the regular exercises. Students should be encouraged to do all the self-review exercises and check their answers.

49 Exercises (Count Includes Separate Parts)
Each chapter concludes with a substantial set of exercises including simple recall of important terminology and concepts; writing individual MFC statements; writing small portions of functions and classes; writing complete MFC functions, classes and applications; and writing major term projects. The variety of exercises enables instructors to tailor their courses to the unique needs of their audiences and to vary course assignments each semester. Instructors can use these exercises to form homework assignments, short quizzes, and major examinations. NOTE: Please do not write to us requesting the solutions to the exercises. Distribution of the solutions is strictly limited to college professors teaching from the book. Instructors may obtain the solutions only from their regular Prentice Hall representatives.

Approximately 1129 Index Entries (with approximately 1942 Page References)
We have included an extensive Index at the back of the book. This helps the student find any term or concept by keyword. The Index is useful to people reading the book for the first time and is especially useful to practicing programmers who use the book as a reference. Each of the 437 terms in the Terminology sections appears in the Index (along with many more index items from each chapter). Students can use the Index in conjunction with the Terminology sections to be sure they have covered the key material of each chapter.

Bibliography
An extensive bibliography is included to encourage further reading.

A Tour of the Book

This book contains five chapters, an Internet and World Wide Web resource appendix, and a bibliography. Each chapter contains examples that carefully illustrate Visual C++ and MFC concepts. Each chapter concludes with a summary, a terminology list, a list of programming tips, self-review exercises (with answers) and exercises (without answers).

Chapter 1: Visual C++ Integrated Development Environment introduces the basics of the Microsoft Visual Studio 6 integrated development environment (IDE); discusses the online documentation; explains how to create, save and execute a Windows console application (i.e., an application that does not use graphical user interface elements such as windows and buttons) and discusses the debugger. Helpful integrated development environment features such as syntax color highlighting--the coloring of keywords, comments and values for emphasis--are discussed. This chapter introduces the concept of a project-a group of program files associated with an application that resides in a specific directory. All programs compiled in Visual C++ use projects.

The debugger helps programmers find code that, although it does not violate C++ syntax, contains logic errors (e.g., infinite loops, division-by-zero exceptions, off-by-one errors, etc.) that prevent the program from executing correctly. The debug toolbar and menu contain the tools necessary to debug a C++ application. Capabilities such as watching variable values change as a program executes are discussed. Chapter 1 is designed to be taught as early as possible in your curriculum to allow students to develop programs using the Visual C++ IDE. Note: The debugger section references functions and should therefore be taught after Chapter 3 "Functions" in C++ How to Program: Second Edition.

Chapter 2: MFC Programming: Part I introduces Windows programming (i.e., creating programs that have GUIs) with MFC and event-driven programming--writing code that responds to user interactions with programs (such as button clicks). Each "live-code" example presents one or two new concepts in a short, concise fashion. Each example includes screen captures showing the user's interaction with the program at execution time.

In this chapter we overview some of the classes in the MFC hierarchy. We outline the subset of MFC classes we present in this introductory book. We also provide a "high-level" discussion of MFC events--called messages--that describes the code needed for event-driven programming. We introduce the Hungarian notation convention for naming identifiers used in Microsoft's MFC documentation and widely practiced in the MFC programming community. We also list (step-by-step) how to create a project for a Windows application with a graphical user interface (i.e., a Visual C++ program that uses MFC).

The first program is our classic "Welcome to" program. It introduces the minimal code needed to implement an MFC application. The second example demonstrates how to create menus. The program creates a series of menus containing food-related items. When a food-item is selected, its price is added to a running total. This example introduces message handling and a message box window for displaying text to the user. The last "live-code" example introduces the edit text control (i.e., a control for accepting input), buttons and dialog-based applications.

Because MFC is a class hierarchy it uses inheritance. Chapters 2 through 5 should be taught after Chapter 9 "Inheritance" in C++ How to Program: Second Edition.

Chapter 3: MFC Programming: Part II continues the Windows programming discussion started in Chapter 2. This chapter contains 4 "live-code" examples. The first example demonstrates password protection for edit text controls by masking input with asterisks. In this example, we also enhance message box windows by adding predefined icons. The second example demonstrates how to handle mouse messages. In this example, we demonstrate how to code mouse handlers to determine the coordinates of a mouse click and to determine which mouse button was clicked. This example also introduces basic graphics by drawing directly on the window. The third "live-code" example demonstrates how to code key handlers (i.e., handlers that execute when a key on the keyboard is pressed). In this example, we create a simple text editor. The last example builds upon the graphics techniques introduced earlier in the chapter by drawing centered-red text in the window.

Chapter 4: Graphical User Interface Controls presents 5 MFC controls for enhancing GUIs. We carefully selected these controls based upon our experience with GUI design using Visual J++ and Visual Basic. The set of controls we present is fundamental to Windows programming.

The first "live-code" example demonstrates how to create and use a multiline edit text control. This example allows the user to type text into a multiline edit control as if it were a simple text editor. The second example demonstrates toggle controls called check boxes. A control--called a group box--for grouping other controls is also introduced. The third "live-code" example introduces mutually-exclusive toggle controls called radio buttons. This example demonstrates how radio buttons are combined into groups and how they differ from check boxes. The last two examples demonstrate controls (list boxes and combo boxes) that provide a lists of strings. We discuss how to add strings to these controls and how to remove strings from these controls.

Chapter 5: Graphics. We thought you might enjoy an introductory chapter on graphics, so we went one step further in this book than just introducing GUI programming. Unfortunately, graphics are not included as part of ANSI/ISO C++, so graphics may be a new topic to many C++ programmers. MFC provides a rich collection of classes and functions for creating and manipulating graphics. As with the previous chapters, we have carefully selected introductory MFC features that are demonstrated using five "live-code" examples.

We present the topic of colors that allow graphics to "come-alive" by discussing the RGB (red, green and blue) values that form a color. We provide a list of RGB values for common colors in a table.

The first "live-code" example draws a rectangle and a solid-red ellipse in a window. The program demonstrates how to create brushes (objects that specify color and fill patterns of an enclosed area) and pens (objects that specify line color, thickness and pattern).

The second "live-code" example builds upon the first example by introducing additional brush and pen features and by introducing functions for drawing lines and polygons. This example draws a rectangle and a solid-green arrow in a window.

Our third "live-code" example introduces the timer object which sends a message to a message handler after a specified number of milliseconds has elapsed. Timers have numerous applications, especially in graphics where shapes can be drawn at different coordinates when the timer message is received--creating a simple animation. In this example, we animate the colors inside a rectangle by manipulating each individual pixel's color.

The fourth "live-code" example demonstrates how a bitmap image can be displayed in a window and the fifth example introduces fonts. We discuss how to manipulate the font name, size and weight. Font manipulation is important for emphasizing and de-emphasizing text.

Appendix A: Resources and Demos lists some popular sites on the World Wide Web pertaining to Visual C++ and MFC. A Bibliography is included to encourage further reading.

Read More Show Less

Customer Reviews

Average Rating 5
( 1 )
Rating Distribution

5 Star

(1)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Anonymous

    Posted August 27, 2004

    A great starting book for MFC programming

    I'd been struggling for a while with the tutorial examples in the MSDN library, and another book I had was more 'do this and it will work', rather than 'this is how function x works'. This book has really hit the spot, and I've been able to write some simple MFC programs and fully understand how they work. Just about every line of code is explained clearly, so there are no problems with snippets of code being left as a mystery. The book doesn't use the wizards for quick MFC programming - I see that as a plus. This way you learn more about how the actual code works, rather than taking it for granted. Besides, it is very easy to have a play with the wizards and tinker with the code after gaining the knowledge from the book. This book isn't the definitive guide to MFC, but then it doesn't claim to be. It is an excellent starter book, one I heartily recommend.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)