Windows编程

Windows编程
作 者: Charles Petzold
出版社: 北京大学出版社
丛编项: 微软编程圣典丛书
版权说明: 本书为公共版权或经版权方授权,请支持正版图书
标 签: Windows
ISBN 出版时间 包装 开本 页数 字数
未知 暂无 暂无 未知 0 暂无

作者简介

  CharlesPetzold1994年5月,Petzold作为仅有的七个人之一(并且是唯一的作家)被《WindowMagazine》和Microsoft公司授予WindowsPioneer奖,以表彰他对MicrosoftWindows的成功做出的贡献。CharlesPetzold从1984年开始编写个人计算机程序,从1985年开始编写MicrosoftWindows程序。他在《MicrosoftSystemsJoumal》1986年12月号上发表了第一篇关于Windows程序设计的杂志论文。从1986年到1995年,他为《PCMagazine》撰写“Environments”专栏,给读者介绍了Windows和OS/2程序设计的许多方面。>>更多作品

内容简介

本书是关于Windows程序设计的最具权威性的技术指南,由微软Windows开发小组核心成员CharlesPetzold编写。随着技术的不断更新,本书几经修改(现已是第5版),因而包含的内容也是最新最全面的,涵盖了从基本输入输出、对话框、图形等到Internet和intranet编程的全部内容,读者如有Windows开发方面的疑问,都可以从中找到答案。配套光盘含有应用程序的源代码和可执行文件,以及本书电子版。总之,本书以其权威性和实用性成为各个层次程序员的必备参考书。

图书目录

Author''s Note

The Basics

section I The Basics

Chapter 1 Getting Started

THE WINDOWS ENVIRONMENT

A History of Windows

Aspects of Windows

Dynamic Linking

WINDOWS PROGRAMMING OPTIONS

APIs and Memory Models

Language Options

The Programming Environment

API Documentation

YOUR FIRST WINDOWS PROGRAM

A Character-Mode Model

The Windows Equivalent

The Header Files

Program Entry Point

The MessageBox Function

Compile, Link, and Run

Chapter 2 An Introduction to Unicode

A BRIEF HISTORY OF CHARACTER SETS

American Standards

The World Beyond

EXtending ASCll

Double-Byte Character Sets

Unicode to the Rescue

WIDE CHARACTERS AND C

The Char Data Type

Wider Characters

Wide-Character Library Functions

Maintaining a Single Source

WIDE CHARACTERS AND WINDOWS

Windows Header File Types

The Windows Function Calls

Windows'' String Functions

Using printf in Windows

A Formatting Message Box

Internationalization and This Book

Chapter 3 Windows and Messages

A WINDOW OF ONE''S OWN

An Architectural Overview

The HELLOWIN Program

Thinking Globally

Registering the Window Class

Creating the Window

Displaying the Window

The Message Loop

The Window Procedure

Processing the Messages

Playing a Sound File

The WM--PAINT Message

The WM--DESTROY Message

THE WINDOWS PROGRAMMING HURDLES

Don''t CaII Me, l''II Call You

Queued and Nonqueued Messages

Get In and Out Fast

Chapter 4 An Exercise In Text Output

PAINTING AND REPAINTING

The WM_PAINT Message

Valid and Invalid Rectangles

AN INTRODUcTION TO GDI

The Device Context

Getting a Device Context Handle: Method One

The Paint Information Structure

Getting a Device ConteXt Handle: Method Two

TextOut.The Details

The System Font

The Size of a Character

TeXt Metrics: The Details

Formatting Text

Putting It All Together

The SYSMETS1 .C Window Procedure

Not Enough Room

The Size of the Client Area

SCRoLL BARS

Scroll Bar Range and Position

Scroll Bar Messages

Scrolling SYSMETS

Structuring Your Program for Painting

BUILDING A BETTER SCROLL

The Scroll Bar Information Functions

How Low Can You Scroll

The New SYSMETS

But l Don''t Like to Use the Mouse

Chapter 5 Basic Drawing

THE STRUCTURE OF GDI

The GDI Philosophy

The GDI Function Calls

The GDI Primitives

Other Stuff

THE DEVlCE CONTEXT

Getting a Device Context Handle

Getting Device Context Information

The DEVCAPS1 Program

The Size of the Device

Finding Out About Color

The Device Context Attributes

Saving Device Contexts

DRAWING DOTS AND LINES

Setting Pixels

Straight Lines

The Bounding Box Functions

Bezier Splines

Using Stock Pens

Creating, Selecting, and Deleting Pens

Filling in the Gaps

Drawing Modes

DRAWING FILLED AREAS

The Polygon Function and the Polygon-Filling Mode

Brushing the Interior

THE GDI MAPPING MODE

Device Coordinates and Logical Coordinates

The Device Coordinate Systems

The Viewport and the Window

Working with MM_TEXT

The Metric Mapping Modes

The Roll Your Own Mapping Modes

The WHATSIZE Program

RECTANGLES, REGIONS, AND CLIPPlNG

Working with Rectangles

Random Rectangles

Creating and Painting Regions

Clipping with Rectangles and Regions

The CLOVER Program

Chapter 6 The Keyboard

KEYBOARD BASICS

lgnoring the Keyboard

Who''s Got the Focus

Queues and Synchronization

Keystrokes and Characters

KEYSTROKE MESSAGES

System and Nonsystem Keystrokes

Virtual Key Codes

The IParam Information

Shift States

Using Keystroke Messages

Enhancing SYSMETS for the Keyboard

CHARACTER MESSAGES

The Four Character Messages

Message Ordering

Control Character Processing

Dead-Character Messages

KEYBOARD MESSAGES AND CHARACTER SETS

The KEYVIEW1 Program

The Foreign-Language Keyboard Problem

Character Sets and Fonts

What About Unicode

TrueType and Big Fonts

THE CARET NOT THE CURSOR

The Caret Functions

The TYPER Program

Chapter 7 The Mouse

MOUSE BASICS

Some Quick Definitions

The Plural Of Mouse Is...

CLIENT-AREA MOUSE MESSAGES

Simple Mouse Processing: An Example

Processing Shift Keys

Mouse Double-Clicks

NONCLIENT-AREA MOUSE MESSAGES

The Hit-Test Message

Messages Beget Messages

HIT-TESTING IN YOUR PROGRAMS

A Hypothetical Example

A Sample Program

Emulating the Mouse with the Keyboard

Add a Keyboard Interface to CHECKER

Using Child Windows for Hit-Testing

Child Windows in CHECKER

Child Windows and the Keyboard

CAPTURING THE MOUSE

Blocking Out a Rectangle

The Capture Solution

The BLOKOUT2 Program

THE MOUSE WHEEL

StilI t0 Come

chapter 8 The Timer

TIMER BASICS

The SyStem and the Timer

Timer Messages Are Not Asynchronous

USING THE TIMER: THREE METHODS

Method One

Method Two

Method Three

USING THE TIMER FOR A CLOCK

Building a Digital Clock

Getting the Current Time

Displaying Digits and Colons

Going International

Building an Analog Clock

USING THE TIMER FOR A STATUS REPORT

Chapter 9 Child Window Controls

THE BUTTON CLASS

Creating the Child Windows

The Child Talks to Its Parent

The Parent Talks to Its Child

Push Buttons

Check Boxes

Radio Buttons

Group Boxes

Changing the Button Text

Visible and Enabled Buttons

Buttons and Input Focus

CONTROLS AND COLORS

System Colors

The Button Colors

The WM_CTLCOLORBTN Message

Owner-Draw Buttons

THE STATIC CLASS

THE SCROLL BAR CLASS

The COLORS1 Program

The Automatic Keyboard Interface

Window Subclassing

Coloring the Background

Coloring the Scroll Bars and Static Text

THE EDIT CLASS

The Edit Class Styles

Edit Control Notification

Using the Edit Controls

Messages to an Edit Control

THE LISTBOX CLASS

List Box Styles

Putting Strings in the List Box

Selecting and Extracting Entries

Receiving Messages from List Boxes

A Simple List Box Application

Listing Files

A head for Windows

Chapter 10 Menus and Other Resources

ICONS, CURSORS, STRINGS, AND CUSTOM RESOURCES

Adding an Icon to a Program

Getting a Handle on Icons

Using lcons in Your Program

Using Customized Cursors

Character String Resources

Custom Resources

MENUS

Menu Concepts

Menu Structure

Defining the Menu

Referencing the Menu in Your Program

Menus and Messages

A Sample Program

Menu Etiquette

Defining a Menu the Hard Way

Floating Popup Menus

Using the System Menu

Changing the Menu

Other Menu Commands

An Unorthodox Approach to Menus

KEYBOARD ACCELERATORS

Why You Should Use Keyboard Accelerators

Some Rules on Assigning Accelerators

The Accelerator Table

Loading the Accelerrator Table

Translating the Keystrokes

Receiving the Accelerator Messages

POPPAD with a Menu and Accelerators

Enabling Menu ltems

Processing the Menu Options

Chapter 11 Dialog Boxes

MODAL DIALOG BOXES

Creating an ''Abour'' Dialog Box

The Dialog Box and Its Template

The Dialog Box Procedure

Invoking the Dialog Box

Variations on a Theme

A More Complex Dialog Box

Working with Dialog Box Controls

The OK and Cancel Buttons

Avoiding Global Variables

Tab Stops and Groups

Painting on the Dialog Box

Using Other Functions with Dialog Boxes

Defining Your Own Controls

MODELESS DIALOG BOXES

Differences Between Modal and Modeless Dialog Boxes

The New COLORS Program

HEXCALC: Window or Dialog Box

THE COMMON DIALOG BOXES

POPPAD Revisited

Unicode File I/O

Changing the Font

Search and Replace

The One-Function-CalI Windows Program

Chapter 12 The Clipboard

SIMPLE USE OF THE CLIPBOARD

The Standard Clipboard Data Formats

Memory Allocation

Transferring Text to the Clipboard

Getting Text from the Clipboard

Opening and Closing the Clipboard

The Clipboard and Unicode

BEYOND SIMPLE CLIPBOARD USE

Using Multiple Data Items

Delayed Rendering

Private Data Formats

BECOMING A CLIPBOARD VIEWER

The Clipboard Viewer Chain

Clipboard Viewer Functions and Messages

A Simple Clipboard Viewer

section II More Graphics

Chapter 13, Using the Printer

PRINTING FUNDAMENTALS

Printing and Spooling

The Printer Device Context

The Revised DEVCAPS Program

The PrinterProperties Call

Checking for BitBlt Capability

The Simplest Printing Program

PRINTING GRAPHICS AND TEXT

Bare-Bones Printing

Canceling Printing with an Abort Procedure

How Windows Uses AbortProc

Implementing an Abort Procedure

Adding a Printing Dialog Box

Adding Printing to POPPAD

Chapter 14 Bitmaps and Bitbita

BITMAP BASICS

Where Do Bitmaps Come From

BITMAP DIMENSIONS

Color and Bitmaps

Real-World Devices

Bitmap Support in GDI

THE BIT-BLOCK TRANSFER

A Simple BitBlt

Stretching the Bitmap

The StretchBlt Mode

The Raster Operations

The Pattern Blt

THE GDI BITMAP OBJECT

Creating a DDB

The Bitmap Bits

The Memory Device Context

Loading Bitmap Resources

The Monochrome Bitmap Format

Brushes from Bitmaps

Drawing on Bitmaps

The Shadow Bitmap

Using Bitmaps in Menus

Nonrectangular Bitmap Images

Some Simple Animation

Bitmaps Outside the Window

Chapter 15 The Device-Independent Bitmap

THE DIB FILE FORMAT

The OS/2-Style DIB

Bottoms Upl

The DIB Pixel Bits

The Expanded Windows DIB

Reality Check

DIB Compression

Color Masking

The Version 4 Header

The Version 5 Header

Displaying DIB Information

DISPLAYING AND PRINTING

Digging into the DIB

Pixel to Pixel

The Topsy-Turvy World Of DIBs

Sequential Display

Stretching to Fit

Color Conversion, Palettes, and Performance

THE UNION OF DIBs AND DDBS

Creating a DDB from a DIB

From DDB to DIB

The DIB Section

More DIB Section Differences

The File-Mapping Option

ln Summary

Chapter 16 The Palette Manager

USING PALETTES

Video Hardware

Displaying Gray Shades

The Palette Messages

The Palette Index Approach

Querying the Palette Support

The System Palette

Other Palette Functions

The Raster-Op Problem

Looking at the System Palette

PALETTE ANIMATION

The Bouncing Ball

One-Entry Palette Animation

Engineering Applications

PALETTES AND REAL-WORLD IMAGES

Palettes and Packed DIBs

The All-Purpose Palette

The Halftone Palette

Indexing Palette Colors

Palettes and Bitmap Objects

Palettes and DIB Sections

A LIBRARY FOR DIBS

The DIBSTRUCT Structure

The Information Functions

Reading and Writing Pixels

Creating and Converting

The DIBHELP Header File and Macros

The DIBBLE Program

Simple Palettes; Optimized Palettes

Converting Formats

Chapter 17 Text and Fonts

SIMPLE TEXT OUTPUT

The Text Drawing Functions

Device Context Attributes for Text

Using Stock Fonts

BACKGROUND ON FONTS

The Types of Fonts

TrueType Fonts

Attributes or Styles

The Point Size

Leading and Spacing

The Logical Inch Problem

THE LOGICAL FONT

Logical Font Creation and Selection

The PICKFONT Program

The Logical Font Structure

The Font-Mapping Algorithm

Finding Out About the Font

Character Sets and Unicode

The EZFONT System

Font Rotation

FONT ENUMERATION

The Enumeration Functions

The ChooseFont Dialog

PARAGRAPH FORMATTING

Simple Text Formatting

Working with Paragraphs

Previewing Printer Output

THE FUN AND FANCY STUFF

The GDI Path

Extended Pens

Four Sample Programs

Chapter 18 Metafiles

THE OLD METAFILE FORMAT

Simple Use of Memory Metafiles

Storing Metafiles on Disk

Old Metafiles and the Clipboard

ENHANCED MEUFILES

The Basic Procedure

Looking Inside

Metafiles and GDI Objects

Metafiles and Bitmaps

Enumerating the Metafile

Embedding Images

An Enhanced Metafile Viewer and Printer

Displaying Accurate Metafile Images

Scaling and Aspect Ratios

Mapping Modes in Metafiles

Mapping and Playing

section III Advanced Topics

Chapter 19 The Multiple-Document Interface

MDI CONCEPTS

The Elements of MDI

MDI Support

A SAMPLE MDI IMPLEMENTATION

Three Menus

Program Initialization

Creating the Children

More Frame Window Message Processing

The Child Document Windows

Cleaning Up

Chapter 20 Multitasking and Multithreading

MODES OF MULTITASKING

Multitasking Under DOS

Nonpreemptive Multitasking

PM and the Serialized Message Queue

The Multithreading Solution

Multithreaded Architecture

Thread Hassles

The Windows Advantage

New! Improved! Now with Threads!

WINDOWS MULTITHREADING

Random Rectangles Revisited

The Programming Contest Problem

The Multithreaded Solution

Any Problems

The Benefits of Sleep

THREAD SYNCHRONIZATION

The Critical Section

EVENT SIGNALING

The BlGJOB1 Program

The Event Object

THREAD LOCAL STORAGE

Chapter 21 Dynamic-Link Libraries

LIBRARY BASICS

Library: One Word, Many Meanings

A Simple DLL

The Library Entry and Exit Point

The Test Program

Shared Memory in DLLs

The STRPROG Program

Sharing Data Among STRPROG Instances

MISCELLANEOUS DLL TOPICS

Dynamic Linking Without Imports

Resource-Only Libraries

Chapter 22 Sound and Music

WINDOWS AND MULTIMEDIA

Multimedia Hardware

An API Overview

Exploring MCI with TESTMCI

MCITEXT and CD Audio

WAVEFORM AUDlO

Sound and Waveforms

Pulse Code Modulation

The Sampling Rate

The Sample Size

Generating Sine Waves in Software

A Digital Sound Recorder

The MCI Alternative

The MCI Command String Approach

The Waveform Audio File Format

Experimenting with Additive Synthesis

Waking Up to Waveform Audio

MIDI AND MUSIC

The Workings of MIDI

The Program Change

The MIDI Channel

MIDI Messages

An Introduction to MIDI Sequencing

Playing a MIDI Synthesizer from the PC Keyboard

A MIDI Drum Machine

The Multimedia time Functions

RIFF File I/O

Chapter 23 A Taste of the Internet

WINDOWS SOCKETS

Sockets and TCP/IP

Network Time Services

The NETTIME Program

WININET ANO FTP

Overview of the FTP API

The Update Demo

Index