MFC与WINDOWS编程:第2版

MFC与WINDOWS编程:第2版
作 者: Microsoft公司著
出版社: 北京大学出版社
丛编项: 微软编程圣典丛书
版权说明: 本书为出版图书,暂不支持在线阅读,请支持正版图书
标 签: MFC
ISBN 出版时间 包装 开本 页数 字数
未知 暂无 暂无 未知 0 暂无

作者简介

暂缺《MFC与WINDOWS编程:第2版》作者简介

内容简介

本书是《微软编程圣典丛书(影印版)》之一,讲述如何在32位Windows平台上使用MFC(微软基本类库)进行程序设计,内容涉及全新COM、OLE和ActiveX,事件驱动程序设计,位图,多线程等。为了增加本书的实用性,特以配套光盘的形式提供了丰富的程序实例以及本书的电子版。本书由微软公司组织专家编写,具有相当的技术深度,是中、高级程序员必备的参考书。Microsoft强大的C++类库可以用于Windows API,本书对其中被公认为具有权威性的部分作了扩充说明,用全新的COM、OLE和ActiveX更新了旧的内容。对MFC编程的基本概念和技巧作了精湛的阐述,然后说明了如何将它们熟练地用于32位Windows平台上的面向对象的开发。配套光盘内容:本书示例程序的源代码及可执行程序,本书电子版。

图书目录

Acknowledgments

Introduction

Part 1 Fundamentals of Widnows and MFC

Capter 1 Hello,MFC

THE WINDOWS PROGRAMMING MODEL

Messages,Messages,and More Messages

Widnows Programming ,SDK-Style

Hungarian Notation and Windows Data Types

SDK Programming in Perspective

INTRODUCING MFC

The Benefits of Using C++ and MFC

The MFC Design Philosophy

The Document/View Architecture

The MFC Class Hierarchy

AFX Functions

YOUR FIRST MFC APPLICATION

The Application Object

How MFC Uses the Application Object

The Frame Window Object

Painting the Window

The Message Map

How Message Maps Work

Widnows,Character Sets,and the_T Macro

Building the Application

The Big Picture

Chapter 2 Drawing in a Window

THE WINDOWS GDI

The MFC Device Context Classes

Device Context Attributes

The Drawing Mode

The Mapping Mode

Programmable Mapping Modes

Coordinate Conversions

Moving the Origin

A Final Word on Coordinate Systems

Getting Information About a Device

DRAWING WITH THE GDI

Drawing Lines and Curves

Drawing Ellipses,Polygons,and Other Shapes

GDI Pens and the CPen Class

GDI Brushes and the CBrush Class

Drawing Text

GDI Fonts and the CFont Class

Raster Fonts vs. TrueType Fonts

Rotated Text

Stock Objects

Deleting GDI Objects

Deselecting GDI Objects

The Ruler Application

SEEING WHAT YOU’VE DRAWN

Addign a Scroll Bar to a Window

Setting a Scroll Bar’s Range,Position,and Page Size

Synchronizing the Thumb Size and the Window Size

Processing Scroll Bar Messages

Scrolling a Window

The Accel Application

LOOSE ENDS

Chapter 3 The Mouse and the Keyboard

GETTING INPUT FROM TEH MOUSE

Client-Area Mouse Messages

The TicTac Application

Nonclient-Area Mouse Messages

The WM_NCHITTEST Message

The WM_MOUSELEAVE and WM_MOUSEHOVER Messages

The Mouse Wheel

Capturing the Mouse

Mouse Capturing in Action

The Cursor

The Hourglass Cursor

Mouse Miscellanea

GETTING INPUT FROM THE KEYBOARD

The Input Focus

Keystroke Messages

Virtual Key Codes

Shift States and Toggles

Character Messages

Dead-Key Messages

The Caret

THE VISUALKB APPLICATION

Handling the Caret

Entering and Editing Text

Other Points of Interest

Chapter 4 Menus

MENU BASICS

Creating a Menu

Loading and Displaying a Menu

Responding to Menu Commands

Command Ranges

Updating the Items in a Menu

Update Ranges

Keyboard Accelerators

THE SHAPES APPLICATION

Running the MFC AppWizard

Analyzing AppWizard’s Output

Beyond AppWizard

The Process in Review

MENU MAGIC

Creating Menus Programmatically

Modifying Menus Programmatically

The System Menu

Owner-Draw Menus

Cascading Menus

Context Menus

THE COLOR APPLICATION

The Context Menu

On Your Own

Chapter 5 The MFC Collection Classes

ARRAYS

The MFC Array Classes

Dynamic Array Sizing

Creating Type-Safe Array Classes with CArray

LISTS

The MFC List Classes

Creating Type-Safe List Classes with CList

MAPS

The MFC Map Classes

How Maps Work

Optimizing Lookup Efficency

Creating Type-Safe Map Classes with CMap

THE TYPED POINTER CLASSES

Chapter 6 File I/O and Serialization

THE CFILE CLASS

Opening,Closing,and Creating Files

Reading and Writing

CFile Derivatives

Enumerating Files and Folders

SERIALIZATION AND THE CARCHIVE CLASS

Serialization Basics

Writing Serializable Classes

Versioning Serializable Classes:Versionable Schemas

How Serialization Works

Serializing CObjects

Chapter 7 Controls

THE CLASSIC CONTROLS

The CButton Class

The CListBox Class

The CStatic Class

The FontView Application

The CEdit Class

Presto!Instant Notepad

The CComboBox Class

The CScrollBar Class

ADVANCED CONTROL PROGRAMMING

Numeric Edit Controls

Owner-Draw List Boxes

Graphical Push Buttons

Customizing a Control’s Colors

Message Reflection

Chapter 8 Dialog Boxes and Property Sheets

MODAL DIALOG BOXES AND THE CDIALOG CLASS

The Dialog Box Template

The CDialog Class

Creating a Modal Dialog Box

Dialog Data Exchange and Dialog Data Validation

Interacting with the Controls in a Dialog

The DlgDemo1 Application

MODELESS DIALOG BOXES

The DlgDemo2 Application

USING A DIALOG BOX AS A MAIN WINDOW

PROPERTY SHEETS

The PropDemo Application

THE COMMON DIALOGS

Modifying the Common Dialogs

The Phones Application

Part II The Document/View Architecture

Chapter 9 Documents,Views,and the Single Document Interface

DOCUMENT/VIEW FUNDAMENTALS

The InitInstance Function Revisited

The Document Object

The View Object

The Frame Window Object

Dynamic Object Creation

More on the SDI Document Types with the Operating System Shell

Command Routing

Predefined Command IDs and Command Handlers

YOUR FIRST DOCUMENT/VIEW APPLICATION

The SdiSquares Application

SdiSpuares Step by Step

DOC+VIEW=LESS WORK FOR YOU

Chapter 10 Scroll Views,HTML Views,and Other View Types

SCROLL VIEWS

CScrollView Basics

CScrollView Operations

Optimizing Scrolling Performance

The ScrollDemo Application

Converting and Ordinary View into a Scroll View

HTML VIEWS

CHtmlView Operations

CHtmlView Overridables

Utilizing DHTML in CHtmlView-Based Applications

Tree Views

Initializing a Tree View

Tree View Member Functions and Notifications

The DriveTree Application

LIST VIEWS

Initializing a List View

Changing the Presentation Style

Sorting in a List View

Hit-Testing in a List View

The WinDir Application

DO-IT-YOURSELF CONTROL VIEWS

Chapter 11 Multiple Documents and Multiple Views

MFC AND THE MULTIPLE DOCUMENT INTERFACE

Synchronizing Multiple Views of a Document

The MdiSquares Application

Supporting Multiple Document Types

Aleternatives to MDI

SPLITTER WINDOWS

Dynamic Splitter Windows

The Sketch Application

Static Splitter Windows

The Wanderer Application

Custom Command Routing

Three-Way Splitter Windows

Dynamic Splitter Windows with Multiple View Types

Chapter 12 Toolbars,Status Bars,and Rebars

TOOLBARS

Creating and Initializing a Toolbar

Docking and Floating

Controlling a Toolbar’s Visibility

Keeping Toolbar Buttons in Sync with Your Application

Adding ToolTips and Flyby Text

Adding Non-Push-Button Controls to a Toolbar

Updating Non-Push-Button Controls

Making Toolbar Settings Persistent

Toolbar Support in AppWizard

STATUS BARS

Creating and Initializing a Status Bar

Providing Context-Sensitive Help for Menu Items

Creating Custom Status Bar Panes

Status Bar Support in AppWizard

PUTTING IT ALL TOGETHER:THER MYWORD APPLICATION

The Main Toolbar

The Sytle Bar

More About CRichEditView

REBARS

Chapter 13 Printing and Print Previewing

PRINTING WITH DOCUMENTS AND VIEWS

The Windows Print Architecture

The MFC Print Architecture

Print Previewing

A BARE-BONES PRINTING APPLICATION

Black-and-White Print Previews

A MORE COMPLEX PRINTING APPLICATION

A Unique Approach to Serialization

PRINTING TIPS AND TRICKS

Using the Print Dialog’s Selection Button

Assume Nothing-And Test Thoroughly!

Adding Default Pagination Support

Enumerating Printers

Part III Beyond the Basics

Chapter 14 Timers and Idle Processing

TIMERS

Setting a Timer:Method 1

Responding to WM_TIMER Messages

Setting a Timer:Method 2

Stopping a Timer

THE CLOCK APPLICATION

Processing Timer Messages

Getting the Current Time:The CTime Class

Using the MM_ISOTROPIC Mapping Mode

Hiding and Displaying the Title Bar

Implementing Client-Area Drag

Using the System Menu as a Context Menu

Topmost Windows

Making Configuration Settings Persistent

Controlling the Window Size:The WM_GETMINMAXINFO Message

IDLE PROCESSING

Using OnIdle

Idle Processing vs.Multithreading

Chapter 15 Bitmaps,Palettes,and Regions

PALETTES

How Windows Uses Color

Logical Palettes and the CPalette Class

Creating a Logical Palette

Realizing a Logical Palette

Drawing with Palette Colors

The WM_QUERYNEWPALETTE and WM_PALETTECHANGED Messages

Determining Whether a Logical Palette Is Needed

The PaletteDemo Application

Palette Animation

The::SetSystemPaletteUse Function

BITMAPS

DDBs and the CBitmap Class

Blitting Bitmaps to Screens and Other Devices

Bitmap Resources

DIBs and DIB Sections

Blits,Raster Operations,and Color Mapping

The BitmapDemo Application

Writing a BMP File Viewer

More on the ::LoadImage Function

REGIONS

Regions and the CRgn Class

The RegionDemo Application

Chapter 16 The Common Controls

COMMON CONTROL FUNDAMENTALS

Creating a Common Control

Processing Notifications:The WM_NOTIFY Message

SLIDER,SPIN BUTTON,AND TOOL TIP CONTROLS

Slider Controls

Spin Button Controls

ToolTip Controls

The GridDemo Application

IMAGE LISTS AND COMBOBOXEX CONTROLS

Image Lists

ComboBoxEx Controls

The PathList Application

PROGRESS CONTROLS AND ANIMATION CONTROLS

Progress Controls

Animation Controls

IP ADDRESS CONTROLS AND OTHER DATA-ENTRY CONTROLS

IP Address Controls

Hotkey Controls

Month Calendar Controls

Date-Time Picker Controls

Chapter 17 Threads and Thread Synchronization

THREADS

Creating a Worker Thread

Creating a UI Thread

Suspending and Resuming Threads

Putting Threads to Sleep

Terminating a Thread

Autodeleting CWinThreads

Terminating Another Thread

Threads,Processes,and Priorities

Using C Run-Time Functions in Multithreaded Applications

Calling MFC Member Functions Across Thread Boundaries

Your First Multithreaded Application

THREAD SYNCHRONIZATION

Critical Sections

Mutexes

Events

Semaphores

The CSingleLock and CMultiLock Classes

Writing Thread-Safe Classes

The ImageEdit Application

ODDS AND ENDS

Message Pumps

Launching Other Processes

File Change Notifications

Part IV COM,OLE,and ActiveX

Chapter 18 MFC and the Component Object Model

THE COMPONENT OBJECT MODEL

Instantiating a COM Object

Object Lifetimes

Acquiring Interface Pointers

COM Servers

Location Transparency

Object Linking and Embedding

Active Documents

ActiveX

MFC AND COM

Multiple Inheritance

Nested Classes

MFC and Nested Classes

How MFC Implements IUnknown

Interface Maps

MFC and Aggregation

MFC and Class Factories

Putting It All in Perspective

Chapter 19 The Clipboard and OLE Drag-and-Drop

THE LEGACY CLIPBOARD

Clipboard Formats

Private Clipboard Formats

Providing Data in Multiple Formats

Querying for Available Data Formats

Delayed Rendering

Building a Reusable Clipboard Class

THE OLE CLIPBOARD

OLE Clipboard Basics

MFC,Global Memory,and the OLE Clipboard

Using Alternative Storage Media

Treating the OLE Clipboard as a CFile

Multiple Formats and Multiple Storage Media

Checking Data Availability

Delayed Rendering with COleDataSource

COleDataSource and COleDataObject in Review

OLE DRAG-AND-DROP

Anatomy of a Drop Source

Anatomy of a Drop Target

MFC Support for OLE Drag-and-Drop

Drop Target Scrolling

PUTTING IT ALL TOGETHER:THE WIDGET APPLICATION

The AfxOleInit Function

Chapter 20 Automation

AUTOMATION BASICS

IDispatch:The Root of All Automation

Automation Data Types

Late Binding vs.Early Binding

Dual Interfaces

Type Libraries

MFC AUTOMATION SERVERS

MFC,IDispatch,and Dispatch Maps

Writing an Automation Server

Adding Automation Methods

Adding Automation Properties

A Simple Automation Server

Automation Hierarchies

A More Complex Automation Server

MFC AUTOMATION CLIENTS

The PieClient Application

Connecting to a Running Automation Server

Chapter 21 ActiveX Controls

ACTIVEX CONTROL BASICS

Methods,Properties,and Events

Custom vs.Stock

Ambient Properties

Control States

The ActiveX Control Architecture

ActiveX Control Containers

MFC Support for ActiveX Controls

BUILDING ACTIVEX CONTROLS

Running ControlWizard

Implementing OnDraw

Using Ambient Properties

Adding Methods

Adding Properties

Adding Properties Persistent

Customizing a Control’s Property Sheet

Adding Pages to a Control’s Property Sheet

Adding Events

Event Maps

Building an ActiveX Control

Testing and Debugging an ActiveX Control

Registering an ActiveX Control

USING ACTIVEX CONTROLS IN MFC APPLICATIONS

Calling an ActiveX Control’s Methods

Processing Events

The CalUser Application

Using ActiveX Controls in Nondialog Windows

Using ActiveX Controls in Web Pages

ADVANCED TOPICS

Windowless Controls

Control Subclassing

Control Licensing

Index