Developing Professional Applications in Windows 95 and NT sing MFC

Similar documents
Visual C++ 2. Developing Professional Applications in Windows 95 and NT Using MFC. Marshall Brain th Lance Lovette

SHRI ANGALAMMAN COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE VISUAL PROGRAMMING UNIT I

DEPARTMENT OF INFORMATION TECHNOLOGY ACADEMIC YEAR EVEN SEMESTER QUESTION BANK. UNIT I WINDOWS PROGRAMMING Part-A (2-MARKS)

KINGS COLLEGE OF ENGINEERING PUNALKULAM DEPARTMENT OF INFORMATION TECHNOLOGY QUESTION BANK UNIT - I WINDOWS PROGRAMMING PART A (2 MARKS)

Windows Programming Using MFC and Visual C ++.Net

Prentice Hall CBT Systems X In A Box IT Courses

Acknowledgments Introduction. Part I: Programming Access Applications 1. Chapter 1: Overview of Programming for Access 3

Binghamton University. EngiNet. State University of New York

1 INTRODUCTION. Purpose. Audience. Figure 1-0. Table 1-0. Listing 1-0.

SDKs - Eclipse. SENG 403, Tutorial 2

Acknowledgments Introduction. Chapter 1: Introduction to Access 2007 VBA 1. The Visual Basic Editor 18. Testing Phase 24

VB.NET Web : Phone : INTRODUCTION TO NET FRAME WORK

Visual HTML5. Human Information Interaction for Knowledge Extraction, Interaction, Utilization, Decision making HI-I-KEIUD

DataViews Visual C++ Tutorial Guide. DataViews for Windows Version 2.2

Visual Programming 1. What is Visual Basic? 2. What are different Editions available in VB? 3. List the various features of VB

MFC One Step At A Time By: Brandon Fogerty

Exercises for Delphi Advanced Programming Technology (English Version)

TABLE OF CONTENTS PREFACE CHAPTER1 INTRODUCING WINDOWS++ 1

2. OpenGL in a Window System

CENTAUR S REAL-TIME GRAPHIC INTERFACE V4.0 OPERATOR S MANUAL

С and the Programming for Multitasking. Thomas W. Schultz. Purdue University West Lafayette, Indiana

Programming Graphical

Code Finix Label Designer V 1.0 User Guide

Subject to Change Drawing Application 1 Introducing Computers, the Internet and C#

VBA for AutoCAD 2002:

HE COMPLETE OPENGL PROGI FOR WINDOW WIND

3 Welcome Application 41 Introduction to Visual Programming

A Web-Based Introduction

PL/SQL Developer 7.0 New Features. December 2005

C# Programming: From Problem Analysis to Program Design. Fourth Edition

ощ 'ршорвшэш! цвн-эориэу ощ 'sajbpossv # PIPG DUJ 'ssjmoossv ^ PIPG pipa w н OX ЛЮН VAV

Contents. Table of Contents. Table of Contents... iii Preface... xvii. Getting Started iii

Developing Microsoft.NET Applications for Windows (Visual Basic.NET)

END-TERM EXAMINATION

Excel Programming with VBA (Macro Programming) 24 hours Getting Started

Murach s Beginning Java with Eclipse

Before You Begin 1 Graphing Application 1 Introducing Computers, the Internet and Visual Basic.NET

"Charting the Course... MOC A Introduction to Web Development with Microsoft Visual Studio Course Summary

Creating and editing vector maps

Chapters and Appendix F are PDF documents posted online at the book s Companion Website (located at

Lesson 7 Software Fundamentals

ECE 480 Application Note. By: Jacob Hersha 4/3/15. Creating a Sequence of Media with Visual Studio

for StarCore DSP Architectures Quick Start for the Windows Edition

Contents. More Controls 51. Visual Basic 1. Introduction to. xiii. Modify the Project 30. Print the Project Documentation 35

James Foxall. Sams Teach Yourself. Visual Basic 2012 *24. Hours. sams. 800 East 96th Street, Indianapolis, Indiana, USA

CS410. Note: VuGujranwala.com is not responsible for any solved solution, but honestly we are trying our best to Guide correctly.

CX Supervisor. CX-Supervisor Features:

Protect Your Investment In Asure ID. Thank You For Purchasing Asure ID Let s Get Started! Section 1 Installing Asure ID

Python Scripting for Computational Science

CHAPTER 1: INTRODUCTION TO THE IDE 3

Microsoft.NET Programming (C#, ASP.NET,ADO.NET, VB.NET, Crystal Report, Sql Server) Goal: Make the learner proficient in the usage of MS Technologies

ASIC-200 Version 5.0. integrated industrial control software. HMI Guide

Text box. Command button. 1. Click the tool for the control you choose to draw in this case, the text box.

At the shell prompt, enter idlde

Pre-installation Information

Coding Faster: Getting More Productive with Microsoft Visual

"Charting the Course... Intermediate PHP & MySQL Course Summary

Introduction to C++/CLI 3. What C++/CLI can do for you 6 The rationale behind the new syntax Hello World in C++/CLI 13

This page intentionally left blank

Microsoft Windows 7 is an operating system program that controls:

Enterprise Client Software for the Windows Platform

17. Introduction to Visual Basic Programming

Chapters are PDF documents posted online at the book s Companion Website (located at

TxWin 5.xx Programming and User Guide

PYTHON. p ykos vtawynivis. Second eciitiovl. CO Ve, WESLEY J. CHUN

MyProgram m i ng Lab. get with the programming. Through the power of practice and immediate personalized

VALLIAMMAI ENGINEERING COLLEGE

Figures, Tables, and Listings

"Charting the Course to Your Success!" MOC D Querying Microsoft SQL Server Course Summary

CS410 Visual Programming Solved Online Quiz No. 01, 02, 03 and 04. For Final Term Exam Preparation by Virtualians Social Network

SCO Vision2K 2.1. What s in this release

Build Your Own Framework with Visual FoxPro

Merits of QT for developing Imaging Applications UI

Course Outline. Writing Reports with Report Builder and SSRS Level 1 Course 55123: 2 days Instructor Led. About this course

What's New in Access 2000 p. 1 A Brief Access History p. 2 Access the Best Access Ever p. 5 Microsoft Office Developer Features p.

Acknowledgments...xvii. Introduction... Chapter 1: Getting Started Chapter 2: Build a Hi-Lo Guessing Game App!... 19

Python Scripting for Computational Science

DHANALAKSHMI SRINIVASAN COLLEGE OF ENGINEERING AND TECHNOLOGY ACADEMIC YEAR (ODD SEM)

Textadept Quick Reference

Introduction. This tutorial introduces the following SingleStep features:

MFC, ATL, and WFC Is MFC Dead?

Part 18. Developer 2000

Reset Cursor Tool Clicking on the Reset Cursor tool will clear all map and tool selections and allow tooltips to be displayed.

Software Program User Manual

"Charting the Course... Java Programming Language. Course Summary

5.1 SR-2 Release Overview

Tutorial E D I T. Editing TIN Geodata T I N. TNTmips. and TNTedit

1 OBJECT-ORIENTED PROGRAMMING 1

Starting Microsoft Visual Studio 6.0 And Exploring Available Controls Tools

.NET FRAMEWORK. Visual C#.Net

Introduction to the Visual Studio.NET Integrated Development Environment IDE. CSC 211 Intermediate Programming

MySQL for Developers with Developer Techniques Accelerated

COURSE PROFILE: ENVISION USER TRAINING

Beyond CSE143. What s Left To Do? Templates. Using Templates. A Template Class. A Problem with Reusing Code CSE 143

Pro Business Applications with Silverlight 4

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 22: Remote Procedure Call (RPC)

Omnis Programming. TigerLogic Corporation. June

CLIM 2.0 Release Notes and Installation Guide. Overview of CLIM 2.0. CLIM 2.0 is a new release of CLIM whose primary goal is to provide support for

Overview of Adobe Fireworks

Transcription:

m^ Developing Professional Applications in Windows 95 and NT sing MFC Marshall Brain Lance Lovette To join a Prentice Hall PTR internet mailing list, point to http://www.prenhall.com/register Prentice Hall PTR Upper Saddle River, New Jersey 07458 http://www.prenhall.com

Preface Version Free xiii Audience xiv Organization xiv The CD-ROM and the On-line Index xv Contacting the Authors: Questions, Comments, and Version Changes xv Acknowledgments xvi xiii Getting Your Bearings 1 What is Visual C++? 2 Available Documentation 3 7. Road Map 4 Common Questions 5 Part 1 Visual C++and MFC Basics, 11 1 Introduction 13 1.1 What is the Microsoft Foundation Class Library? 13 1.2 Windows Vocabulary 14 1.3 Event-driven Sofiware and Vocabulary 16 1.4 An Example 19 1.5 Conclusion 20 2 Understanding an MFC Program 21 2.1 An Introduction to MFC 21 2.2 Designing a Program 23 2.3 Understanding the Code for "Hello World" 23 2.4 Completing the Program 30 2.5 MFC Application Structure 32 2.6 Conclusion 32 3 Customizing Controls 33 3.1 The Basics 33 3.2 CStatic Styles 36 3.3 CStatic Text Appearance 37

3.4 Rectangular Display Modes for CStatic 44 3.5 Fonts 47 3.6 Conclusion 48 4 Handling Events 49 4.1 Understanding Message Maps 49 4.2 The CButton Class 50 4.3 Creating a Message Map 52 4.4 Sizing Messages 54 4.5 Window Messages 57 4.6 Scroll Bar Controls 60 4.7 Understanding Message Maps 64 4.8 Conclusion 64 5 Simple Applications 67 5.1 Designing an Application 67 5.2 Implementing the Fahrenheit to Celsius Converter 69 5.3 The CEdit Control 74 5.4 An Interest Calculator 77 5.5 Conclusion 81 Part 2 Visual C+ + and MFC Details 83 6 Resources, Dialogs, and Menus 85 6.1 Resources and Resource Files 85 6.2 The Icon Resource 88 6.3 Creating a Resource File 90 6.4 Menus 92 6.5 Responding to Menus 96 6.6 Dialog Resources 100 6.7 String Resources 106 6.8 Conclusion 109 7 Canned Dialogs 111 7.1 The Message Box Dialog 111 7.2 The File Open/Save Dialog 115 7.3 The Font Dialog 120 7.4 The Color Dialog 123 7.5 The Print Dialog 124 7.6 The Find/Replace Dialog 127

77 Conclusion 132 8 Edit Controls and Editors 133 8.1 Using the CEdit Control in Single-Line Mode 133 8.2 Using the CEdit Control in Multi-Line Mode 136 8.3 Designing a Simple Text Editor 139 8.4 Creating the Editor Application 140 8.5 Stubbing in the Menu Handlers 144 8.6 Implementing the Editor 150 8.7 Conclusion 161 9 Lists 163 9.1 Creating a List Box 163 9.2 Alternate Display Formats 167 9.3 Getting User Selections 170 9.4 Manipulating Items in a List 174 9.5 Combo Boxes 175 9.6 Conclusion 177 10 The CWinApp class 179 10.1 Member Variables 179 10.2 Icons and Cursors 181 10.3 Handling Idle Time 185 10.4 Application Functionality 186 10.5 Initialization Features 190 10.6 Miscellaneous Features 192 10.7 Conclusion 192 11 Drawing 195 11.1 Introduction to the GDI Library 195 11.2 GDI Basics 196 11.3 Device Contexts 198 11.4 Simple Drawing 200 11.5 Using the Mouse with Your Drawings 222 11.6 Advanced Drawing Concepts 249 11.7 Conclusion 261 12 Utility Classes 263 12.1 Utility Classes 264 12.2 Simple Array Classes 278 12.3 The CObject class and CObject Arrays 282 12.4 List Classes 291

12.5 Mapping Classes 295 12.6 Conclusion 298 13 Debugging and Robustness 299 13.1 Setting Up 299 13.2 Assertions 300 13.3 Tracing 305 13.4 Dumping 307 13.5 Memory State 309 13.6 Exceptions 313 13.7 Other Debugging Features 321 13.8 Conclusion 321 Part 3 Using; the Visual C+ + Wizards and Tools to Create Applications 323 14 Understanding the AppWizard and ClassWizard 325 14.1 The Goal of the App Wizard 325 14.2 Creating a Simple Framework with the AppWizard 327 14.3 The AppWizard's Document-Centric Approach 327 14.4 Understanding the AppWizard's Files 329 14.5 Understanding the ClassWizard 333 14.6 Conclusion 335 15 Creating a Drawing Program 337 15.1 The Goal of the Application 337 15.2 Creating a Drawing Program 338 15.3 Understanding the Drawing Program 347 15.4 Creating an MDI Application 352 15.5 Scrolling 356 15.6 Splitter Windows 362 15.7 Adding New Menu Options and Dialogs. 371 15.8 Printing 380 15.9 Conclusion 388 16 Creating an Editor with CEditView 391 16.1 Creating an MDI Text Editor 391 16.2 Understanding the Editor 392 16.3 Combining Two Documents and Views in a Single

Application 394 16.4 Fixing a Subtle Problem 397 16.5 Handling Multiple Views on One Document 398 16.6 Conclusion 399 17 Creating a Fahrenheit-to-Celsius Converter 401 17.1 Creating the Converter 401 17.2 Understanding the Program 404 17.3 Using DDX 405 17.4 Using the Document Class 406 17.5 Using Form Views 410 17.6 Conclusion 411 1.8 Creating an Address List Application 413 18.1 Creating the Application 413 18.2 Understanding the Address List Program 424 18.3 Understanding DDX and DDV 425 18.4 Improving the Application 427 18.5 Printing 445 18.6 Conclusion 450 19 Context-Sensitive Help 453 19.1 Understanding the App Wizards Help Framework 453 19.2 Understanding and Modifying the Help Files 454 19.3 Context-Sensitive Help 460 19.4 Aliases 463 19.5 Conclusion 463 20 Common Controls 465 20.1 A Simple Example Using the Spin Button, List, and Tree Controls 465 20.2 CSpinButtonCtrl 466 20.3 CListCtrl 466 20.4 CTreeCtrl 469 20.5 Property Sheets 470 20.6 A Property Sheet Example 470 20.7 The CPropertySheet Class 471 20.8 Conclusion 473

21 Creating Explorers 475 21.1 Creating the basic framework 476 21.2 Conclusion 480 Part 4 Advanced Features 481 22 Dialog Data Exchange and Validation 483 22.1 Understanding DDX 484 22.2 Exchange Routines 485 22.3 Transfer Direction 486 22.4 Understanding DDV 486 22.5 An Example 487 22.6 Custom Routines 493 22.7 Conclusion 494 23 Understanding MFC 495 23.1 What Are Window Handles? 495 23.2 The Life of Windows and Objects 497 23.3 Initializing Dialogs 498 23.4 From HWND to CWnd 499 23.5 Permanent and Temporary Associations 501 23.6 Handles to Other Objects 501 23.7 How Messages Work 501 23.8 Subclassing 503 23.9 Conclusion 504 24 Enhancing The Edit Control 505 24.1 An Example 505 24.2 Understanding the Process 506 24.3 Conclusion 507 25 Self-Managing Controls 509 25.1 Owner-Drawing vs. Self-Drawing 510 25.2 Owner-Drawn Messages 510 25.3 The Self Drawing Framework 510 25.4 Behind the Scenes 511 25.5 A General Solution 511

25.6 A Self-Drawing Combo Box 513 25.7 Drawing Transparent Bitmaps 517 25.8 Subclassing the Combo Box 520 25.9 Conclusion 521 26 Another Look 523 A Self-Drawing List Box 26.1 Introduction to Font Enumeration 523 26.2 Enumerating Font Families 524 26.3 Enumerating Font Styles 527 26.4 An Example 528 26.5 Conclusion 532 / Creating A Splash Screen 533 27.1 An Example 533 27.2 Conclusion 537 28 Expanding Dialogs 539 28.1 The CExpandingDialog Class 539 28.2 An Example 545 28.3 Conclusion 546 29 Drawing and Controls 547 29.1 Drawing in CStatic Controls 547 29.2 Drawing in Dialogs 550 29.3 Dialog Controls and the Background 552 29.4 Conclusion 552 30 Dialog Bars 555 30.1 An Example 556 30.2 Data Exchange 558 30.3 Conclusion 559 31 Dialog and View Idle Command Updating 561 31.1 How Idle Updates Work 561 31.2 Idle Updating in Views 562 31.3 An Example 563 31.4 Idle Updating in Dialogs 563 31.5 An Example 565 31.6 Conclusion 566

32 Odds and Ends 567 32.1 Accepting Files from the File Manager 567 32.2 Making an Application the Topmost Window 568 32.3 Starting an Application Minimized 569 32.4 Modeless Dialog Boxes 569 32.5 Mini-Frame Windows 571 32.6 Context Popup Menus 574 32.7 Modifying the System Menu 576 32.8 Conclusion 576 Part 5 Advanced MFC Classes 577 33 Database Access 579 33.1 Understanding Relational Databases 579 33.2 Understanding SQL 582 33.3 Understanding ODBC 585 33.4 Microsoft Query 586 33.5 The CRecordSet Class 591 33.6 Simple CRecordSet Operations 593 33.7 Using the CRecordView Class 602 33.8 Adding and Deleting Records 605 33.9 Conclusion 607 34 OLE 609 34.1 Understanding OLE 609 34.2 An Example 614 34.3 OLE as a Vision of the Future 617 34.4 Standard OLE Features 618 34.5 An Introduction to OLE Containers 621 34.6 An Lntroduction to OLE Servers 629 34.7 An Introduction to OLE Automation 636 34.8 An Introduction to OLE Controls 640 34.9 Conclusion 650 35 MFC Threads 651 35.1 Understanding the Possibilities 651 35.2 Understanding Threads 652 35.3 MFC Worker Threads 655 35.4 Thread Termination 657

35.5 Passing Parameters to Threads 660 35.6 Suspending and Resuming Threads 661 35.7 Thread Priorities 662 35.8 Subclassing CWin Thread 667 35.9 User Interface Threads 675 35.10 Conclusion 677 A В Understanding C++: An Accelerated Introduction 679 Using the Visual C++ Compiler and Tools 739 B. 1 Compiling and Executing a Console Program with Visual C++ 739 B.2 Debugging 744 B.3 Compiling MFC Programs 747 B. 4 The Browser 752 B.5 Resources and resource files 756 B.6 AppWizard Files 761 B.7 Using the ClassWizard 769 B.8 OLE Controls 775 B.9 Conclusion 781 С Contacting the Authors 783 D Using OpenGL with MFC 785 D.l Writing an OpenGL Program 785 D.2 Simple 2-D Graphics 791 D.3 Transformations and the Matrix Stack 793 D.4 Mouse Action 796 D.5 Double Buffering 797 D.6 A Three Dimensional Cube 798 D.7 Z-Buffering 801 D. 8 Conclusion 802 Index 803