Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Programming Windows®, Fifth Edition
Author’s Note
I. The Basics
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
2. An Introduction to Unicode
A Brief History of Character Sets
American Standards
The World Beyond
Extending ASCII
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
3. Windows and Messages
A Window of One’s Own
An Architectural Overview
The HELLOWIN Program
Thinking Globally
The Windows Function Calls
Uppercase Identifiers
New Data Types
Getting a Handle on Handles
Hungarian Notation
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 Call Me, I’ll Call You
Queued and Nonqueued Messages
Get In and Out Fast
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 I Don’t Like to Use the Mouse
5. Basic Drawing
The Structure of GDI
The GDI Philosophy
The GDI Function Calls
The GDI Primitives
Other Stuff
The Device 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 MM_ISOTROPIC Mapping Mode
MM_ANISOTROPIC: Stretching the Image to Fit
The WHATSIZE Program
Rectangles, Regions, and Clipping
Working with Rectangles
Random Rectangles
Creating and Painting Regions
Clipping with Rectangles and Regions
The CLOVER Program
6. The Keyboard
Keyboard Basics
Ignoring the Keyboard
Who’s Got the Focus?
Queues and Synchronization
Keystrokes and Characters
Keystroke Messages
System and Nonsystem Keystrokes
Virtual Key Codes
The lParam Information
Repeat Count
OEM Scan Code
Extended Key Flag
Context Code
Previous Key State
Transition State
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.
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
Still to Come
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
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
Using file attribute codes
Ordering file lists
A head for Windows
10. Menus and Other Resources
Icons, Cursors, Strings, and Custom Resources
Adding an Icon to a Program
Getting a Handle on Icons
Using Icons 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 Accelerator Table
Translating the Keystrokes
Receiving the Accelerator Messages
POPPAD with a Menu and Accelerators
Enabling Menu Items
Processing the Menu Options
11. Dialog Boxes
Modal Dialog Boxes
Creating an “About” 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-Call Windows Program
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
II. More Graphics
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
14. Bitmaps and Bitblts
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
15. The Device-Independent Bitmap
The DIB File Format
The OS/2-Style DIB
Bottoms Up!
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
In Summary
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
File Loading and Saving
Displaying, Scrolling, and Printing
The Clipboard
Flipping and Rotating
Simple Palettes; Optimized Palettes
The Uniform Distribution
The “Popularity” Algorithm
The “Median Cut” Algorithm
Converting Formats
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
18. Metafiles
The Old Metafile Format
Simple Use of Memory Metafiles
Storing Metafiles on Disk
Old Metafiles and the Clipboard
Enhanced Metafiles
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
III. Advanced Topics
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
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 BIGJOB1 Program
The Event Object
Thread Local Storage
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
22. Sound and Music
Windows and Multimedia
Multimedia Hardware
An API Overview
Exploring MCI with TESTMCI
MCITEXT and CD Audio
Waveform Audio
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
23. A Taste of the Internet
Windows Sockets
Sockets and TCP/IP
Network Time Services
The NETTIME Program
WinInet and FTP
Overview of the FTP API
The Update Demo
Index
About the Author
Copyright
← Prev
Back
Next →
← Prev
Back
Next →