Microsoft Visual C++ 2005 Express Edition Programming for the Absolute Beginner byAaron MillerandJerry Lee Ford, Jr Course Technology 2006 (408 pages) ISBN:159200816X Written in a straight-forward style, using a gamesbased approach that makes learning beginning-level programming fun and easy, this book focuses on teaching first time programmers how to program using Visual C++ 2005 Express Edition as a foundation Table of Contents Microsoft Visual C++ 2005 Express Edition Programming for the Absolute Beginner Introduction Chapter 1 - An Introduction to Visual C++ 2005 Express Chapter 2 - Navigating the Visual C++ 2005 Express Edition Environment Chapter 3 - Creating an Application Interface Chapter 4 - Working with Menus and Toolbars Chapter 5 - Storing and Retrieving Data in Memory Chapter 6 - Applying Conditional Logic Chapter 7 - Processing Lots of Data with Loops Chapter 8 - Enhancing Code Structure and Organization Chapter 9 - Getting Comfortable with Object-Oriented Programming Chapter 10 - Integrating Graphics and Audio Chapter 11 - Debugging Visual C++ Applications Appendix A - What's on the Companion Web Site? Appendix B - What's Next? Index List of Figures List of Tables List of In The Real Worlds Back Cover Microsoft Visual C++ 2005 Express Edition Programming for the Absolute Beginner focuses on teaching first time programmers how to program using Visual C++ 2005 Express Edition as a foundation language Written for the entry-level user, the book assumes no prior programming or scripting experience Whether you are a new or experienced C++ developer, this book delivers the tools and libraries you need to write a variety of programs Written in a straightforward style, using a games-based approach that makes learning beginning-level programming fun and easy, Microsoft Visual C++ 2005 Express Edition Programming for the Absolute Beginner is the perfect introductory programming book About the Authors Aaron Miller is a software developer with more than 15 years of experience He has worked in a number of diverse fields, including the computer game industry, healthcare, and embedded systems development He is passionate about demystifying technology and has long been a mentor to students new to programming Jerry Lee Ford, Jr is an author, educator, and an IT professional with more than 16 years of experience in information technology, including roles as an automation analyst, technical manager, technical support analyst, automation engineer, and security analyst Jerry has a master's degree in business administration from Virginia Commonwealth University in Richmond, Virginia He also is the author of 15 other books, including Microsoft Visual Basic 2005 Express Edition Programming for the Absolute Beginner, VBScript Professional Projects, Microsoft Windows Shell Scripting and WSH Administrator's Guide, Learn VBScript in a Weekend, Microsoft Windows Shell Scripting for the Absolute Beginner, Learn JavaScript in a Weekend, and Microsoft Windows XP Professional Administrator's Guide He has more than five years of experience as an adjunct instructor teaching networking courses in information technology Microsoft Visual C++ 2005 Express Edition Programming for the Absolute Beginner Aaron Miller with Jerry Lee Ford, Jr Thomson Course Technology PTR, a division of Thomson Course Technology 25 Thomson Place Boston, MA 02210 http://www.courseptr.com © 2006 by Thomson Course Technology PTR All rights reserved No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system without written permission from Thomson Course Technology PTR, except for the inclusion of brief quotations in a review The Thomson Course Technology PTR logo and related trade dress are trademarks of Thomson Course Technology and may not be used without written permission Microsoft and Visual Basic are registered trademarks of Microsoft Corporation in the United States and/or other countries All other trademarks are the property of their respective owners Important: Thomson Course Technology PTR cannot provide software support Please contact the appropriate software manufacturer's technical support line or Web site for assistance Thomson Course Technology PTR and the authors have attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following the capitalization style used by the manufacturer Information contained in this book has been obtained by Thomson Course Technology PTR from sources believed to be reliable However, because of the possibility of human or mechanical error by our sources, Thomson Course Technology PTR, or others, the Publisher does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from use of such information Readers should be particularly aware of the fact that the Internet is an ever-changing entity Some facts may have changed since this book went to press Educational facilities, companies, and organizations interested in multiple copies or licensing of this book should contact the publisher for quantity discount information Training manuals, CD-ROMs, and portions of this book are also available individually or can be tailored for specific needs ISBN: 1-59200-816-x Library of Congress Catalog Card Number: 2005924928 Printed in the United States of America 06 07 08 09 10 PH 10 9 8 7 6 5 4 3 2 1 Publisher and General Manager, Thomson Course Technology PTR: Stacy L Hiquet Associate Director of Marketing: Sarah O'Donnell Manager of Editorial Services: Heather Talbot Marketing Manager: Heather Hurley Acquisitions Editor: Mitzi Koontz Marketing Coordinator: Jordan Casey Project/Copy Editor: Karen A Gill Technical Reviewer: Jonathan Harbour PTR Editorial Services Coordinator: Elizabeth Furbish Interior Layout Tech: Shawn Morningstar Cover Designer: Mike Tanamachi Indexer: Kelly Talbot Proofreader: Gene Redding Dedication To my good friends Melissa and Jerusha, angels of encouragement —Aaron Miller Acknowledgments This book would not have been possible without the hard work of many people I'd especially like to thank Dave Astle, Ernest Pazera, and the many fantastic members of GameDev.net for their help and advice I'd also like to thank this book's copy editor, Karen Gill, and technical editor, Jonathan Harbour, for helping me to keep everything on track —Aaron Miller About the Author Aaron Miller is a software developer with more than 15 years of experience He has worked in a number of diverse fields, including the computer game industry, healthcare, and embedded systems development He is passionate about demystifying technology and has long been a mentor to students new to programming Jerry Lee Ford, Jr is an author, educator, and an IT professional with more than 16 years of experience in information technology, including roles as an automation analyst, technical manager, technical support analyst, automation engineer, and security analyst Jerry has a master's degree in business administration from Virginia Commonwealth University in Richmond, Virginia He also is the author of 15 other books, including Microsoft Visual Basic 2005 Express Edition Programming for the Absolute Beginner, VBScript Professional Projects, Microsoft Windows Shell Scripting and WSH Administrator's Guide, Learn VBScript in a Weekend, Microsoft Windows Shell Scripting for the Absolute Beginner, Learn JavaScript in a Weekend, and Microsoft Windows XP Professional Administrator's Guide He has more than five years of experience as an adjunct instructor teaching networking courses in information technology Jerry lives in Richmond, Virginia, with his wife, Mary, and their children, William, Alexander, and Molly Introduction Whether you're a student, a game mod maker, or just someone who is interested in learning to program, Microsoft Visual C++ 2005 Express Edition is a powerful way to introduce yourself to the C++ programming language The Express Edition comes complete with the tools that make creating, managing, and maintaining your projects simple and easy It helps you to become a more effective programmer by allowing you to put projects together quickly, focus only on the important details, and get the hints and help you need when you need them Microsoft Visual C++ 2005 Express Edition is part of the Microsoft Visual Studio 2005 line of products This powerful series includes Visual Basic, Visual C#, and Visual J# The Microsoft Visual Studio 2005 line has become the top choice of today's professional programmer, garnering awards from leading industry magazines such as PC Week and PC Magazine You can find versions of each product being used throughout the software engineering world By mastering the Express Edition toolset, you give yourself a competitive edge when it comes to learning one of the latest technologies available to the programming industry WHY VISUAL C++ 2005 EXPRESS EDITION? With so many products to choose from, it might be hard to decide which best fits your needs Each language has its strengths But if you are looking for the most powerful among them, Microsoft Visual C++ 2005 Express Edition is it The Express Edition allows you to employ the NET Framework, a new coding technology that is growing in popularity The NET Framework facilitates the construction of applications that can be run on Windows, smart devices like the PocketPC, and the Web With it, you can write code modules in Visual C++ and use them in Visual Basic, Visual C#, or Visual J# The NET Framework features many new enhancements to make your programs more robust and secure Microsoft has designed this new version of Visual C++ to be the most flexible and extensible of its languages It is aimed at writing robust Windows and server-side applications Unlike the other NET languages, Visual C++ lets you directly access the hardware that your machine is running on, enabling you to maximize its full capabilities Visual C++ 2005 Express Edition has many features and capabilities, some of which are tricky to master For this reason, Microsoft has put a strong effort into making the product easier to use The core code library has been redesigned, allowing you to build your programs on a stronger foundation that is easier to read and write Your own code will now be more streamlined thanks to context-sensitive technology that does a better job of understanding what you type Improvements in online help, project management, and the ever-popular IntelliSense reference technology place a wealth of information at your fingertips New features such as WinForms allow you to rapidly create a program graphically You can drag and drop buttons, menus, and other interface elements onto a page to quickly get a program up and working Then you can have the editor generate code for you with a few mouse clicks Chapter 4: Working with Menus and Toolbars Table 4.1: Form Controls for the Lottery Assistant Game Table 4.2: Property Value Assignments for the Lottery Assistant Game's Form Table 4.3: Property Changes for Each of the Label Controls Table 4.4: Property Changes for Each of the TextBox Controls Table 4.5: Menus for the Lottery Assistant Game Table 4.6: Menu Items Residing Under the File Menu Table 4.7: Menu Items Residing Under the Options Menu Table 4.8: Menu Items Residing Under the Help Menu Table 4.9: Menu Items Residing on the Background Submenu Table 4.10: Menu Items Residing on the Font Size Submenu Chapter 5: Storing and Retrieving Data in Memory Table 5.1: Visual C++ Supported Data Types Table 5.2: String Handling Properties and Methods Table 5.3: List of Visual C++ Reserved Words Table 5.4: Form Controls for the Story of Mighty Molly Table 5.5: Property Changes for Form1 Table 5.6: Property Changes for the Label Controls Table 5.7: Property Changes for the Button Controls Table 5.8: Property Changes for the StatusStrip Control Table 5.9: Property Changes for the TextBox Controls Table 5.10: Property Changes for the ToolStripStatusLabel Control Table 5.11: Property Changes for the ProgressBar Control Table 5.12: Property Changes for the ToolTip Control Chapter 6: Applying Conditional Logic Table 6.1: Visual C++ Comparison Operators Table 6.2: Form Controls for the Guess a Number Game Table 6.3: Property Changes for Form1 Table 6.4: Property Changes for the GroupBox Controls Table 6.5: Property Changes for the RadioButton Controls Table 6.6: Property Changes for the Button Controls Table 6.7: Property Changes for the CheckBox Control Table 6.8: Property Changes for the Label Controls Table 6.9: Property Changes for the TextBox Controls Table 6.10: Property Changes for the StatusStrip Control Chapter 7: Processing Lots of Data with Loops Table 7.1: Form Controls for the Dice Poker Game Table 7.2: Property Changes for Form1 Table 7.3: Property Changes for Label Controls Table 7.4: Property Changes for PictureBox Controls Table 7.5: Property Changes for CheckBox Controls Table 7.6: Property Changes for Button Controls Table 7.7: Property Changes for GroupBox Controls Table 7.8: Property Changes for TextBox Control Table 7.9: Bitmap Images to Add to the ImageList Control's Images Collection Chapter 8: Enhancing Code Structure and Organization Table 8.1: Form Controls for the Hangman Game Table 8.2: Property Changes for Form1 Table 8.3: Property Changes for the Panel Control Table 8.4: Property Changes for the GroupBox Control Table 8.5: Property Changes for the TextBox Controls Table 8.6: Property Changes for the Button Control Table 8.7: Property Changes for the Label Controls Table 8.8: Property Changes for the PictureBox Control Table 8.9: Bitmap Images to Add to the ImageList Control's Images Collection Chapter 9: Getting Comfortable with ObjectOriented Programming Table 9.1: Form Controls for the Rock, Paper and Scissors Game Table 9.2: Property Changes for Form1 Table 9.3: Property Changes for PictureBox Controls Table 9.4: Property Changes for Label Controls Table 9.5: Property Changes for Button Controls Table 9.6: Property Changes for TextBox Controls Table 9.7: Property Changes for Timer Control Table 9.8: Bitmap Images to Add to the ImageList Control's Images Collection Chapter 10: Integrating Graphics and Audio Table 10.1: Drawing Methods Associated with the System::Drawing::Graphics Class Table 10.2: Predefined Colors for Pens and Brushes Table 10.3: Form Controls for the VC++ Doodle Game Table 10.4: Property Changes for FormI Table 10.5: Property Changes for Panel Control Table 10.6: Property Changes for Label Controls Table 10.7: Property Changes for Button Controls Table 10.8: Property Changes for ComboBox Control Chapter 11: Debugging Visual C++ Applications Table 11.1: From Controls for the Tic-Tac-Toe Game Table 11.2: Property Changes for Form1 Table 11.3: Property Changes for Panel Controls Table 11.4: Property Changes for PictureBox Controls Table 11.5: Property Changes for Button Controls Table 11.6: Property Changes for Label Control Table 11.7: Property Changes for TextBox Control List of In The Real Worlds Introduction IN THE REAL WORLD Chapter 1: An Introduction to Visual C++ 2005 Express IN THE REAL WORLD IN THE REAL WORLD IN THE REAL WORLD IN THE REAL WORLD IN THE REAL WORLD Chapter 3: Creating an Application Interface IN THE REAL WORLD Chapter 4: Working with Menus and Toolbars IN THE REAL WORLD Chapter 5: Storing and Retrieving Data in Memory IN THE REAL WORLD Chapter 8: Enhancing Code Structure and Organization IN THE REAL WORLD IN THE REAL WORLD ... projects together quickly, focus only on the important details, and get the hints and help you need when you need them Microsoft Visual C++ 2005 Express Edition is part of the Microsoft Visual Studio 2005 line of products... Written in a straightforward style, using a games-based approach that makes learning beginning-level programming fun and easy, Microsoft Visual C++ 2005 Express Edition Programming for the Absolute Beginner is the perfect... interested in learning to program, Microsoft Visual C++ 2005 Express Edition is a powerful way to introduce yourself to the C++ programming language The Express Edition comes complete with the tools that make