Teach Yourself Visual C++ 6 in21 Days phần 1 pdf

80 374 0
Teach Yourself Visual C++ 6 in21 Days phần 1 pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

A Division of Macmillan Computer Publishing 201 West 103rd St., Indianapolis, Indiana, 46290 USA Davis Chapman Visual C++ ® 6 in 21 Days Teach Yourself 000 31240-9 FM 4/27/00 11:02 AM Page i Sams Teach Yourself Visual C++ ® 6 in 21 Days Copyright © 1998 by Sams Publishing All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photo- copying, recording, or otherwise, without written permission from the pub- lisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. International Standard Book Number: 0-672-31240-9 Library of Congress Catalog Card Number: 98-84508 Printed in the United States of America First Printing: August, 1998 01 00 99 98 4 3 2 1 Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Visual C++ is a registered trademark of Microsoft Corporation. Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an “as is” basis. The authors and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages aris- ing from the information contained in this book. EXECUTIVE EDITOR Brad Jones ACQUISITIONS EDITOR Kelly Marshall DEVELOPMENT EDITOR Matt Purcell MANAGING EDITOR Jodi Jensen PROJECT EDITOR Dana Rhodes Lesh COPY EDITOR Kris Simmons INDEXER Erika Millen TECHNICAL EDITOR Larry Richardson PRODUCTION Marcia Deboy Michael Dietsch Jennifer Earhart Cynthia Fields Susan Geiselman 000 31240-9 FM 4/27/00 11:02 AM Page ii Overview Introduction 1 WEEK 1 AT A GLANCE 5 Day 1 The Visual C++ Development Environment—Building Your First Visual C++ Application 7 2 Using Controls in Your Application 25 3 Allowing User Interaction—Integrating the Mouse and Keyboard in Your Application 47 4 Working with Timers 67 5 Getting User Feedback—Adding Dialog Boxes to Your Application 83 6 Creating Menus for Your Application 105 7 Working with Text and Fonts 121 WEEK 1 IN REVIEW 143 W EEK 2 AT A GLANCE 147 Day 8 Adding Flash—Incorporating Graphics, Drawing, and Bitmaps 149 9 Adding ActiveX Controls to Your Application 179 10 Creating Single Document Interface Applications 199 11 Creating Multiple Document Interface Applications 229 12 Adding Toolbars and Status Bars 243 13 Saving and Restoring Work—File Access 279 14 Retrieving Data from an ODBC Database 315 WEEK 2 IN REVIEW 337 W EEK 3 AT A GLANCE 341 Day 15 Updating and Adding Database Records Through ADO 343 16 Creating Your Own Classes and Modules 379 17 Sharing Your Functionality with Other Applications—Creating DLLs 405 000 31240-9 FM 4/27/00 11:02 AM Page iii 18 Doing Multiple Tasks at One Time—Multitasking 429 19 Building Your Own Widgets—Creating ActiveX Controls 473 20 Internet Applications and Network Communications 495 21 Adding Web Browsing Functionality to Your Applications 521 WEEK 3 IN REVIEW 537 A PPENDIXES 541 A C++ Review 541 B Answers 579 C Printing and Print Previewing 637 D Understanding and Exception Handling 661 E Using the Debugger and Profiler 677 F Using MFC’s Helper Classes 699 Index 731 000 31240-9 FM 4/27/00 11:02 AM Page iv Specifying the Control Tab Order 30 Attaching Variables to Your Controls 32 Attaching Functionality to the Controls 33 Closing the Application 36 Showing the User’s Message 37 Clearing the User’s Message 38 Disabling and Hiding the Message Controls 39 Running Another Application 42 Summary 44 Q&A 44 Workshop 45 Quiz 45 Exercises 45 DAY 3ALLOWING USER INTERACTION—INTEGRATING THE MOUSE AND KEYBOARD IN YOUR APPLICATION 47 Understanding Mouse Events 48 Drawing with the Mouse 49 Improving the Drawing Program 53 Adding the Finishing Touches 55 Capturing Keyboard Events 56 Changing the Drawing Cursor 57 Making the Change Stick 60 Summary 64 Q&A 64 Workshop 65 Quiz 65 Exercises 65 DAY 4WORKING WITH TIMERS 67 Understanding Windows Timers 68 Placing a Clock on Your Application 68 Creating the Project and Application 68 Adding the Timer IDs 70 Starting the Clock Timer 71 Handling the Clock Timer Event 72 Adding a Second Timer to Your Application 74 Adding the Application Variables 74 Starting and Stopping the Counting Timer 75 Enabling the Stop Button 79 Summary 81 vi Sams Teach Yourself Visual C++ 6 in 21 Days 000 31240-9 FM 4/27/00 11:02 AM Page vi Q&A 81 Workshop 82 Quiz 82 Exercise 82 DAY 5GETTING USER FEEDBACK—ADDING DIALOG BOXES TO YOUR APPLICATION 83 Using Pre-existing (or System) Dialog Windows 84 Using Message Boxes 84 Using Common Dialogs 90 Creating Your Own Dialog Windows 93 Creating the Dialog Window 93 Using the Dialog in Your Application 96 Summary 101 Q&A 101 Workshop 103 Quiz 103 Exercises 104 DAY 6CREATING MENUS FOR YOUR APPLICATION 105 Menus 106 Menu Styles 106 Keyboard Shortcut–Enabling Menus 106 Menu Standards and Conventions 107 Designing Menus 108 Creating a Menu 108 Creating the Application 108 Adding and Customizing a Menu 109 Attaching the Menu to Your Dialog Window 112 Attaching Functionality to Menu Entries 112 Creating Pop-Up Menus 116 Creating a Menu with Accelerators 118 Summary 119 Q&A 119 Workshop 120 Quiz 120 Exercises 120 DAY 7WORKING WITH TEXT AND FONTS 121 Finding and Using Fonts 122 Listing the Available Fonts 122 Using a Font 125 Contents vii 000 31240-9 FM 4/27/00 11:02 AM Page vii [...]... 60 5 Exercise 60 6 Day 11 61 2 Quiz 61 2 Exercise 61 2 Day 12 61 4 Quiz 61 4 Exercises 61 5 Day 13 61 6 Quiz 61 6 Exercise 61 7 Day 14 62 0 Quiz 62 0 Exercise 62 1 Day 15 62 3 Quiz 62 3 Exercise 62 4... 62 4 Day 16 62 5 Quiz 62 5 Exercises 62 5 Day 17 62 6 Quiz 62 6 Exercises 62 6 Day 18 62 8 Quiz 62 8 Exercises 62 8 Day 19 63 1 xv 000 312 40-9 FM xvi 4/27/00 11 :02 AM Page xvi Sams Teach Yourself Visual C++ 6 in 21 Days Quiz 63 1 Exercises 63 1 Day 20... and EndDoc() 65 9 Using StartPage() and EndPage() 66 0 APPENDIX D UNDERSTANDING AND EXCEPTION HANDLING 66 1 Using Exceptions 66 1 Running Code and Catching the Errors 66 1 Throwing Exceptions 66 6 Deleting Exceptions 66 8 MFC Exception Types 66 8 Using the CException Base Class 66 8 Using the Memory Exception 66 9 Using the Resource... window, as in Figure 1. 12 1 003 312 40-9 CH 01 4/27/00 11 :05 AM 16 Page 16 Day 1 FIGURE 1. 12 Positioning the Cancel button 5 Right-click the mouse over the Cancel button, opening the pop-up menu in Figure 1. 13 Select Properties from the menu, and the properties dialog in Figure 1. 14 opens FIGURE 1. 13 Right-clicking the mouse to open a popup menu FIGURE 1. 14 The Cancel button properties dialog 6 Change the value... further ado, go ahead and jump in and get started 003 312 40-9 CH 01 4/27/00 11 :04 AM Page 7 WEEK 1 DAY 1 The Visual C++ Development Environment—Building Your First Visual C++ Application Welcome to Sams Teach Yourself Visual C++ 6 in 21 Days Over the next three weeks, you will learn how to build a wide variety of applications with Microsoft’s Visual C++ What’s even better is that you will learn how to... the Application 511 Sending and Receiving 515 Ending the Connection 517 Summary 519 Q&A 519 Workshop 520 Quiz 520 Exercise 520 000 312 40-9 FM 4/27/00 11 :02 AM xiv Page xiv Sams Teach Yourself Visual C++ 6 in 21 Days DAY 21 ADDING WEB BROWSING FUNCTIONALITY TO YOUR APPLICATIONS 5 21 The Internet Explorer ActiveX... and editors who worked on the book Fax: 317 - 817 -7070 Email: adv_prog@mcp.com Mail: Executive Editor Programming Macmillan Computer Publishing 2 01 West 10 3rd Street Indianapolis, IN 462 90 USA 0 01 312 40-9 INTRO 4/27/00 11 :03 AM Page 1 Introduction Welcome to Visual C++ Over the next 21 days, you will learn how to use the features that Microsoft has built into its C++ development environment to enable you... Output pane displays any compiler errors 10 Select Build | Execute Hello.exe to run your application 11 Your application presents a dialog with a TODO message and OK and Cancel buttons, as shown in Figure 1. 10 You can click either button to close the application 003 312 40-9 CH 01 4/27/00 11 :05 AM Page 15 Building Your First Visual C++ Application 15 FIGURE 1. 10 The unmodified application shell Designing... developer You’ll also learn a lot about the Visual C++ development environment and the tools that it makes available to you 0 01 312 40-9 INTRO 4/27/00 11 :03 AM 2 Page 2 Sams Teach Yourself Visual C++ 6 in 21 Days By the time you begin the second week, you’ll be doing more and more programming, as the topics become more involved You’ll still be using the Visual C++ tools to construct your applications,... buy this book to read about this book You bought this book to learn how to use Visual C++ to build Windows applications So go ahead and flip the page and get started programming… 3 0 01 312 40-9 INTRO 4/27/00 11 :03 AM Page 4 002 312 40-9 AAG Wk1 4/27/00 11 :04 AM Page 5 WEEK 1 1 At a Glance 2 Welcome to the world of Visual C++ Over the next three weeks, you’ll learn how to build a wide variety of applications . Publishing 2 01 West 10 3rd St., Indianapolis, Indiana, 462 90 USA Davis Chapman Visual C++ ® 6 in 21 Days Teach Yourself 000 312 40-9 FM 4/27/00 11 :02 AM Page i Sams Teach Yourself Visual C++ ® 6 in 21 Days Copyright. Entries 11 2 Creating Pop-Up Menus 1 16 Creating a Menu with Accelerators 11 8 Summary 11 9 Q&A 11 9 Workshop 12 0 Quiz 12 0 Exercises 12 0 DAY 7WORKING WITH TEXT AND FONTS 12 1 Finding and Using Fonts 12 2 Listing. Application 96 Summary 10 1 Q&A 10 1 Workshop 10 3 Quiz 10 3 Exercises 10 4 DAY 6CREATING MENUS FOR YOUR APPLICATION 10 5 Menus 1 06 Menu Styles 1 06 Keyboard Shortcut–Enabling Menus 1 06 Menu Standards

Ngày đăng: 13/08/2014, 08:21

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan