Training
Certifications
Books
Special Offers
Community




 
Programming Windows®, Fifth Edition
Author Charles Petzold
Pages 1520
Disk 1 Companion CD(s)
Level All Levels
Published 11/11/1998
ISBN 9781572319950
Price $59.99
To see this book's discounted price, select a reseller below.
 

More Information

About the Book
Table of Contents
Sample Chapter
Related Series
Related Books
About the Author

Support: Book & CD

Rate this book
Barnes Noble Amazon Quantum Books

 

Table of Contents


Section I    The Basics
Chapter 1    Getting Started 3
The Windows Environment 4
A History of Windows 4
Aspects of Windows 6
Dynamic Linking 8
Windows Programming Options 9
APIs and Memory Models 9
Language Options 10
The Programming Environment 11
API Documentation 12
Your First Windows Program 13
A Character-Mode Model 13
The Windows Equivalent 14
The Header Files 15
Program Entry Point 15
The MessageBox Function 16
Compile, Link, and Run 18
  
Chapter 2    An Introduction to Unicode 19
A Brief History of Character Sets 20
American Standards 20
The World Beyond 21
Extending ASCII 22
Double-Byte Character Sets 24
Unicode to the Rescue 25
Wide Characters and C 26
The char Data Type 26
Wider Characters 27
Wide-Character Library Functions 28
Maintaining a Single Source 29
Wide Characters and Windows 31
Windows Header File Types 31
The Windows Function Calls 33
Windows' String Functions 34
Using printf in Windows 34
A Formatting Message Box 37
Internationalization and This Book 38
  
Chapter 3    Windows and Messages 41
A Window of One's Own 41
An Architectural Overview 42
The HELLOWIN Program 44
Thinking Globally 47
Registering the Window Class 51
Creating the Window 57
Displaying the Window 59
The Message Loop 60
The Window Procedure 62
Processing the Messages 62
Playing a Sound File 63
The WM_PAINT Message 64
The WM_DESTROY Message 66
The Windows Programming Hurdles 66
Don't Call Me, I'll Call You 66
Queued and Nonqueued Messages 68
Get In and Out Fast 70
  
Chapter 4    An Exercise in Text Output 71
Painting and Repainting 72
The WM_PAINT Message 72
Valid and Invalid Rectangles 74
An Introduction to GDI 74
The Device Context 75
Getting a Device Context Handle: Method One 75
The Paint Information Structure 77
Getting a Device Context Handle: Method Two 79
TextOut: The Details 80
The System Font 82
The Size of a Character 82
Text Metrics: The Details 83
Formatting Text 85
Putting It All Together 86
The SYSMETS1.C Window Procedure 94
Not Enough Room 95
The Size of the Client Area 95
Scroll Bars 97
Scroll Bar Range and Position 99
Scroll Bar Messages 100
Scrolling SYSMETS 102
Structuring Your Program for Painting 107
Building a Better Scroll 108
The Scroll Bar Information Functions 108
How Low Can You Scroll? 110
The New SYSMETS 111
But I Don't Like to Use the Mouse 118
  
Chapter 5    Basic Drawing 121
The Structure of GDI 121
The GDI Philosophy 121
The GDI Function Calls 123
The GDI Primitives 124
Other Stuff 125
The Device Context 126
Getting a Device Context Handle 126
Getting Device Context Information 128
The DEVCAPS1 Program 129
The Size of the Device 133
Finding Out About Color 138
The Device Context Attributes 140
Saving Device Contexts 142
Drawing Dots and Lines 143
Setting Pixels 143
Straight Lines 144
The Bounding Box Functions 149
Bezier Splines 156
Using Stock Pens 161
Creating, Selecting, and Deleting Pens 162
Filling in the Gaps 165
Drawing Modes 166
Drawing Filled Areas 168
The Polygon Function and the Polygon-Filling Mode 169
Brushing the Interior 174
The GDI Mapping Mode 176
Device Coordinates and Logical Coordinates 177
The Device Coordinate Systems 178
The Viewport and the Window 179
Working with MM_TEXT 181
The Metric Mapping Modes 183
The "Roll Your Own" Mapping Modes 187
The WHATSIZE Program 192
Rectangles, Regions, and Clipping 196
Working with Rectangles 196
Random Rectangles 198
Creating and Painting Regions 202
Clipping with Rectangles and Regions 204
The CLOVER Program 205
  
Chapter 6    The Keyboard 211
Keyboard Basics 211
Ignoring the Keyboard 212
Who's Got the Focus? 212
Queues and Synchronization 213
Keystrokes and Characters 214
Keystroke Messages 214
System and Nonsystem Keystrokes 215
Virtual Key Codes 216
The lParam Information 219
Shift States 221
Using Keystroke Messages 222
Enhancing SYSMETS for the Keyboard 223
Character Messages 231
The Four Character Messages 232
Message Ordering 233
Control Character Processing 234
Dead-Character Messages 235
Keyboard Messages and Character Sets 236
The KEYVIEW1 Program 236
The Foreign-Language Keyboard Problem 242
Character Sets and Fonts 244
What About Unicode? 255
TrueType and Big Fonts 256
The Caret (Not the Cursor) 263
The Caret Functions 264
The TYPER Program 265
  
Chapter 7    The Mouse 273
Mouse Basics 274
Some Quick Definitions 274
The Plural of Mouse Is… 275
Client-Area Mouse Messages 276
Simple Mouse Processing: An Example 277
Processing Shift Keys 281
Mouse Double-Clicks 283
Nonclient-Area Mouse Messages 284
The Hit-Test Message 285
Messages Beget Messages 286
Hit-Testing in Your Programs 287
A Hypothetical Example 287
A Sample Program 288
Emulating the Mouse with the Keyboard 291
Add a Keyboard Interface to CHECKER 293
Using Child Windows for Hit-Testing 297
Child Windows in CHECKER 297
Child Windows and the Keyboard 303
Capturing the Mouse 309
Blocking Out a Rectangle 309
The Capture Solution 313
The BLOKOUT2 Program 314
The Mouse Wheel 318
Still to Come 326
  
Chapter 8    The Timer 327
Timer Basics 328
The System and the Timer 328
Timer Messages Are Not Asynchronous 329
Using the Timer: Three Methods 330
Method One 330
Method Two 334
Method Three 337
Using the Timer for a Clock 338
Building a Digital Clock 338
Getting the Current Time 343
Displaying Digits and Colons 344
Going International 344
Building an Analog Clock 346
Using the Timer for a Status Report 351
  
Chapter 9    Child Window Controls 357
The Button Class 359
Creating the Child Windows 363
The Child Talks to Its Parent 365
The Parent Talks to Its Child 366
Push Buttons 367
Check Boxes 368
Radio Buttons 369
Group Boxes 369
Changing the Button Text 369
Visible and Enabled Buttons 370
Buttons and Input Focus 370
Controls and Colors 371
System Colors 372
The Button Colors 373
The WM_CTLCOLORBTN Message 374
Owner-Draw Buttons 375
The Static Class 382
The Scroll Bar Class 383
The COLORS1 Program 384
The Automatic Keyboard Interface 392
Window Subclassing 393
Coloring the Background 393
Coloring the Scroll Bars and Static Text 394
The Edit Class 395
The Edit Class Styles 398
Edit Control Notification 399
Using the Edit Controls 399
Messages to an Edit Control 400
The Listbox Class 401
List Box Styles 401
Putting Strings in the List Box 402
Selecting and Extracting Entries 403
Receiving Messages from List Boxes 404
A Simple List Box Application 405
Listing Files 409
A head for Windows 411
  
Chapter 10    Menus and Other Resources 417
Icons, Cursors, Strings, and Custom Resources 418
Adding an Icon to a Program 418
Getting a Handle on Icons 424
Using Icons in Your Program 426
Using Customized Cursors 427
Character String Resources 428
Custom Resources 430
Menus 439
Menu Concepts 440
Menu Structure 440
Defining the Menu 441
Referencing the Menu in Your Program 441
Menus and Messages 442
A Sample Program 445
Menu Etiquette 451
Defining a Menu the Hard Way 452
Floating Popup Menus 453
Using the System Menu 459
Changing the Menu 462
Other Menu Commands 463
An Unorthodox Approach to Menus 464
Keyboard Accelerators 469
Why You Should Use Keyboard Accelerators 469
Some Rules on Assigning Accelerators 470
The Accelerator Table 470
Loading the Accelerator Table 471
Translating the Keystrokes 471
Receiving the Accelerator Messages 472
POPPAD with a Menu and Accelerators 473
Enabling Menu Items 480
Processing the Menu Options 480
  
Chapter 11    Dialog Boxes 483
Modal Dialog Boxes 484
Creating an "About" Dialog Box 484
The Dialog Box and Its Template 488
The Dialog Box Procedure 491
Invoking the Dialog Box 493
Variations on a Theme 494
A More Complex Dialog Box 497
Working with Dialog Box Controls 505
The OK and Cancel Buttons 507
Avoiding Global Variables 509
Tab Stops and Groups 510
Painting on the Dialog Box 512
Using Other Functions with Dialog Boxes 513
Defining Your Own Controls 513
Modeless Dialog Boxes 520
Differences Between Modal and Modeless Dialog Boxes 521
The New COLORS Program 523
HEXCALC: Window or Dialog Box? 529
The Common Dialog Boxes 538
POPPAD Revisited 538
Unicode File I/O 563
Changing the Font 564
Search and Replace 564
The One-Function-Call Windows Program 565
  
Chapter 12    The Clipboard 567
Simple Use of the Clipboard 568
The Standard Clipboard Data Formats 568
Memory Allocation 570
Transferring Text to the Clipboard 572
Getting Text from the Clipboard 573
Opening and Closing the Clipboard 574
The Clipboard and Unicode 575
Beyond Simple Clipboard Use 581
Using Multiple Data Items 581
Delayed Rendering 583
Private Data Formats 584
Becoming a Clipboard Viewer 587
The Clipboard Viewer Chain 587
Clipboard Viewer Functions and Messages 587
A Simple Clipboard Viewer 590
  


NEXT PAGE


Visit Microsoft Press for more information on Programming Windows, Fifth Ed.


Top of Page


Last Updated: Saturday, July 7, 2001