Win32 Programming / Edition 1

Paperback (Print)
Used and New from Other Sellers
Used and New from Other Sellers
from $20.00
Usually ships in 1-2 business days
(Save 73%)
Other sellers (Paperback)
  • All (12) from $20.00   
  • New (6) from $31.24   
  • Used (6) from $20.00   


Windows developers: a thorough understanding of the Windows API will enable you to create applications that are elegant, efficient, and powerful.

You will find comprehensive information on all aspects of Windows GUI programming, such as:

  • Windows Controls, including the common controls
  • GDI, including new features like transformations and geometric pens
  • Printing, including a reusable print engine
  • Common dialogs, including customization
  • Background processing, including synchronization

In addition, the book covers such important advanced topics as creation of Dynamic Link Libraries, storage management, windows subclassing, the Multiple Document Interface (MDI), and threads and their synchronization.

More than just an introductory book, Win32 Programming is a reference to many of the more obscure and sometimes incomprehensible advanced features of the user interface and graphics subsystems. It is useful not only for C programmers but also for C++/MFC programmers because the API forms the basis for most MFC methods. The book's extensive and comprehensive index means you will never again have to search through pages of examples to find the example of the API function you want to see. This book is designed both to teach basic Windows programming and to be a useful companion for years to come.

This book comes in two volumes they both have the same ISBN. 0201634929 B04062001

Volume 1 ends with Chapter 10, Volume 2 begins with Chapter 11.

Read More Show Less

Product Details

  • ISBN-13: 9780201634921
  • Publisher: Addison-Wesley
  • Publication date: 1/6/1997
  • Series: Addison-Wesley Advanced Windows Series
  • Edition description: REVISED, BOOK & CD-ROM
  • Edition number: 1
  • Pages: 1568
  • Product dimensions: 7.79 (w) x 9.60 (h) x 3.15 (d)

Meet the Author

Brent E. Rector is President of Wise Owl Consulting, Inc., a firm that specializes in Windows/COM development and consulting. He also teaches classes on COM, ATL, and MTS for DevelopMentor, a leading COM education firm. He received the Microsoft Annual MVP (Most Valuable Professional) award for his contributions to CompuServe's Windows forums.

Joseph M. Newcomer is head of The Joseph M. Newcomer Company, where he specializes in Windows application design, device drivers, and real-time and embedded systems. He has considerable experience in compiler and operating system design and implementation. A frequent contributor to Dr. Dobb's Journal, he has also written several books, including Win32 Programming (with Brent Rector, Addison-Wesley). In addition to his consulting practice, he serves as adjunct senior scientist at Carnegie Mellon University and has been an active contributor to CompuServe and Internet Windows online forums. Dr. Newcomer is one of the principal authors of IDL: The Language and Its Implementation, and is co-inventor on several patents on distributed information technology. In recognition of these contributions, he was named a Most Valuable Professional (MVP) by Microsoft.


Read More Show Less

Table of Contents

(Most chapters conclude with "Further Reading".)

Welcome xliii.

Tools Required xliii.

Typeface conventions xlv.

Icons for insertions xlv.


Introduction to Windows Concepts.

What Is Windows?

What Is Win32?

An Historical Perspective on User Interfaces.

Differences between a Windows Program and a Typical DOS or Unix Program.

Resource Sharing.

Graphical User Interface.

What about Unix, X, Motif, OS/2, or the Macintosh?

Input Facilities.

Memory Management.

Device-Independent Graphics.

The Windows Programming Model.

The Conceptual Model.

Windows and Their Associated Window Functions.

Windows Queues and the Message Loop.

Windows Operating Modes.

Program Memory Models.

Memory Models and Porting 16-bit Code.

__cdecl and __stdcall Calling Sequences.

Static and Dynamic Linking.

Dynamic Link Libraries.

Exports and Imports, or Who's Looking for Whom?

Windows Memory Management.

The windows.h Header File.

windows.h typedef Declarations.

Getting a Handle on Handles.

Using the Windows C Runtime Libraries and Header Files.

Using Strict Type Checking.

Naming Conventions.

Function Names.

Parameter Names.

Example Code.

Diving Right In.

Further Reading.


A Skeletal Windows Application.

The Skeleton Application Source Program.

The WinMain Function.

The Parameters to WinMain.

WinMain Initialization.

Initialization: initInstance.

WinMain's Message Loop.

The Window Function.

General Structure.

Message Handling: WM_DESTROY.

Message Handling: WM_COMMAND.

The About Dialog Function.

The Components of the Skeleton Application.

Resource Definition Files.

The Skeleton.h Header File.

Building and Running the Skeleton Program.

Message Crackers.

Further Reading.


Exploring Variations on a Window.

Default Behavior for a Window.

My, How Stylish You Look.

Class Styles.

Window Styles.

Overlapped Windows.

Pop-up Windows.

Child Windows.

Other Window Styles.

Extended Window Styles.

The Panes Example Program.

The Panes Source Code.

Class Registration in Panes.

Window Creation in Panes.

Message Handling in Panes.

The Window Explorer.

Further Reading.


Displaying text in a Window.

Device and Display Contexts.

When Do You Get a Display Context?

Displaying Output upon Receipt of a WM_PAINT Message.

How Do You Get a Display Context?

Processing a WM_PAINT Message.

Using TextOut to Display Text.

Logical Coordinates and Device Coordinates.

The MM_TEXT Mapping Mode.

What Do the Characters Look Like?

How to Use Text Metrics.

Displaying Information about the Windows Environment.

Introduction to Scroll Bars.

The Parts of a Scroll Bar.

Scrolling Text.

Subclassing a Window Class.

What is subclassing?

Subclassing Techniques.

The Sysinfo Program.

The Source Code.

Sysinfo Initialization.

Subclassing the System Metrics Window Class.

Displaying the System Metrics.

Scrolling the Window.

Coming Attractions.


Examining a Device Context in Depth.

What Is a Device Context?

Display Contexts: A Specific Type of Device Context.

The Common Display Context.

The Class Display Context.

The Private Display Context.

The Parent Display Context.

The Window Display Context.

Other Types of Device Contexts.

Creating a Device Context.

The Information Context.

The Memory Device Context.

The Metafile Device Context.

The Capabilities of a Device.

The Attributes of a Device Context.

Color Attributes.

Defining a Color.

The Bitmap, Brush, Font, Pen, and Region Attributes and Objects.

Deleting objects.

Special Considerations on Object Selection.

The Mapping Mode, Window Origin and Extent, and Viewport Origin and Extent.

Various Windows Coordinate Systems.

The Viewport and the Window.

The Physical Measurement Mapping Modes.

The Remaining Device Context Attributes.

Saving and Restoring the State of a Device Context.

The DC Explorer.

Further Reading.


Graphical Output: Pixels, Lines, and Polygons.

Getting and Setting the Color of a Pixel.

Lines, Pens, and Drawing Modes.

The GDI Queue.

Drawing Lines.

Creating Pens.

Drawing Modes.

More-complex Lines.

Drawing Filled Areas.

Drawing Rectangles and Ellipses.

Drawing Polygons.

Creating and Using Stock and Custom Brushes.

Stock Brushes.

Custom Brushes.

Creating and Using Bitmaps.

Bitmap Functions.

Creating a Bitmap.

Creating a Bitmap Resource from a Bitmap File.

Creating and Drawing into a Blank Bitmap.

Creating an Initialized Bitmap.

Creating an Initialized Bitmap from a DIB.

The BitBlt, StretchBlt, and StretchDIBits Functions.

The StretchBlt Function.

The StretchDIBits Function.

The MaskBlt and PlgBlt Functions.

The PlgBlt function.

The MaskBlt Function.

Miscellaneous Bitmap and Drawing Functions.

Bitmap Functions.


The DrawEdge Function.

The GDI Batch Queue (in detail).

Region Functions.

Advanced Windows Graphics: Paths and Transformations.

Transformation Matrices.

Regions Revisited: ExtCreateRegion.

Paths: Completely General Shapes for Drawing, Clipping, and Filling.

The GDI Explorer.

What's Next?

Further Reading.


Keyboard, Mouse, and Timer Input.

Keyboard Input.

The Input Focus.

The Key Press and Release Messages.

The Virtual-key Code.

Key Transition Message Crackers.

Character Messages.

The Character Sets.

The Unicode Character Set.

The Caret.

The Keyboard Explorer Program.

Mouse Input.

Mouse Messages.

Hit Testing: The WM_NCHITTEST Message.

Nonclient-area Mouse Messages.

Client-area Mouse Messages.

Capturing the Mouse.

Simple Drag-and-Drop.

The Cursor.

Custom Cursors.

Predefined Cursors.

Displaying the Cursor.

Loading Cursors from Other Sources.

Loading System Cursors.

Setting System Cursors.

Moving the Cursor with the Keyboard.

Towers of Hanoi Example Program.

Timer Input.

Sending WM_TIMER Messages to a Window Function.

Sending WM_TIMER Messages to a Callback Function.

Using the Timer.

Structured Exception Handling.

Further Reading.


Using Controls: Overview; Static, Button, and Edit Classes.

Creating a Control in a Window.

Control Notifications.

Using Controls.

Fonts in Controls.

The STATIC Class.

"Dynamic" Static Controls.

Owner-draw Static Controls.

Simple Frame Example.

The BUTTON Class.

BUTTON Class Styles.

Button Control Notification Messages.

Problems with Buttons and the Input Focus.

Handling Input Focus Changes in Child Windows.

Push Buttons.

Check Boxes.

Radio Buttons.

Owner-draw Buttons.

Group Boxes.

The EDIT Class.

The Edit Class Styles.

Changing Styles.

Messages to an Edit Control.

Working with Selections.

Setting Contents, Copy, Cut, and Paste.

Working with Multiline Edit Controls.

Line Scrolling and Formatting.

Coordinate Mapping.

Edit Control Notification Messages.



Using Controls: ListBox, ComboBox, ImageList, and .

TreeView Classes.

The LISTBOX Class.

The LISTBOX Class Styles.

Messages to a List Box Control.

Adding, Inserting, and Deleting Items from a List Box.

Selecting an Item in a Single-selection List Box.

Determining the Selection in a Single-selection List Box.

Selecting Items in a Multiple-selection or Extended-selection List Box.

Determining the Selection in a Multiple-select List Box.

File Names in List Boxes.

Establishing a Horizontal Scroll Bar.

List Box Notification Messages.


The COMBOBOX Class Styles.

Messages to a Combo Box Control.

Smart Drop-down Lists.

Adding, Inserting, and Deleting Items from a Combo Box.

Selecting an Item in a Combo Box.

Combo Box Notification Messages.

Combo Boxes and List Boxes Are Not Interchangeable.

Improving Performance for List Boxes and Combo Boxes.

Setting Locales for List Boxes and Combo Boxes.

Image Lists.

The TreeView Class.

Messages to Tree View Controls.

Inserting Items in a Tree View.

Selecting an Item.

Getting Information about an Item.

Tree View Notifications.

Image Lists.

Implementing Drag-and-Drop Features.

"Smart" Drag-and-Drop.

Label Editing.

Stop the Presses.

Tree Control Summary.

Further Reading.


Using Controls: Scroll Bar, Trackbar, Up/Down, and .

Progress Classes.


The SCROLLBAR Class Styles.

Messages to a Scroll Bar Control.

Setting Scroll Bar Parameters.

Retrieving Scroll Bar Parameters.

Enabling Scroll Bar Arrows.

Scroll Bar Notifications.

Keyboard Notifications.

Using the Size Box.

The Trackbar Control.

Using Trackbars.

Trackbar Messages.

Simple Trackbars.

Setting the Line and Page Sizes.

Trackbars with Selection.

Tick Marks.

Simple Tick Marks.

Custom Tick Marks.

Problems with Tick Marks in Trackbar Controls.

Stop The Presses News.

Up/Down Controls.

Messages to Up/Down Controls.

Using Up/Down Controls.

Notifications from Up/Down Controls.

Buddy Controls.

Up/Down Accelerators.

The Progress Bar Control.

Stop The Presses.

The Control Explorer.

Further Reading.


Dialog Boxes.

What Is a Dialog Box?

Dialog Functions and Callback Functions.

Modal and Modeless Dialog Boxes.

Modal Dialog Boxes.

Modeless Dialog Boxes.

Using Registered Window Messages.

Creating a Dialog Box.

Using CreateWindow versus CreateDialog.

Passing Parameters When Creating a Dialog Box.


What to Do in the WM_INITDIALOG Handler.

Creating a Dialog Box Template in Your Resource Definition File.

The Pizza-ordering Program.

Resizable Dialogs.

Handling Double-click Activation.

Window-related Data and How to Manage It.


Returning Values from a Dialog.

Using Properties.

Initializing the Pizza Dialog.

Setting Initial Control Values.

Changing the Caption Text.

Enabling and Disabling Controls.

Saving the State of the Dialog.

Using Idle Time to Update Controls.

Some Remaining Problems.

Creating a Dialog Box Using DLGTEMPLATE Structure.

Creating a Dialog Box Template: An Example.

Creating Controls in the Dialog.

Adding Other Control Functions.

The Message Box.

The MessageBox Explorer.


Menus, Accelerators, Icons, String Resources, and MessageTable Resources.


Defining and Creating a Menu.

Defining a Menu Template in Your Resource Definition File.

Win32 4.x Menus.

Creating a Menu Dynamically in Win32 3.x.

Appending, Inserting, and Modifying Menu Items in Win32 3.x.

Creating a Menu Dynamically: Win32 4.x.


Appending, Inserting, and Modifying Menu Items in Win32 4.x.

Radio Button Menu Items.

Default Menu Items.

Summary: A Comparison of Win32 3.x and Win32 4.x Menu Capabilities.

Bitmap Menu Items.

Owner-Draw Menu Items.

Separator Menu Items.

String Menu Items.

Controlling the Appearance of an Item on a Menu in Win32 3.x.

Controlling the Appearance of an Item on a Menu in Win32 4.x.

Creating a Menu Based on a Template.

The Win32 3.x Menu Templates.

The Win32 4.x Menu Templates.

Creating the Menu from a Template.

Class and Window Menus.

Initializing a Menu before It Is Displayed.

Altering a Menu.

Enabling, Disabling, and Graying an Item on a Menu.

Checking and Unchecking a Menu Item.

Using a Bitmap as a Menu Item.

Using a Bitmap as a Custom Menu Item Check Mark.

Menu Messages.

Maintaining Menu State.

Tracking the Menu Selection.

Using a Floating Pop-up Menu.

The System Menu.

The Menus Example Program.

The Menu Explorer.


Creating an Accelerator Table.

Loading an Accelerator Table.

Creating Accelerator Tables Dynamically.

Displaying Accelerators in the Menu.

Accelerators and the Message Loop.

Accelerators without Menu Items.

Icon Resources.

Defining an Icon Resource.

Loading an Icon Resource.

Displaying an Icon Resource.

Class Icons.

The LoadImage Function.

Drawing Icons Yourself.

Switching to a Different Icon.

Displaying Different Icons in Win32 3.x.

Displaying Different Icons in Win32 4.x.

Displaying an Icon in a Dialog Box.

String Resources.

Defining a String Resource.

Localization and Strings.

FormatMessage Function and MESSAGETABLE Resources.

A Formatted MessageBox Function.

The FormatMessage Format String.

The full FormatMessage specification.


Further Reading.



An Overview of the Printing Process.

Using the Default Printer.

Using Any Installed Printer.

Getting the Printer DC for Any Printer.

Checking for Selection Options.

Determining Device Mode Values.

Hazards with Device Mode Values.

Setting the dmTTOption.

The dmPaperSize field.

The dmDefaultSource Field.

Setting Device Mode Values.

Three Elements Required in a Printing Windows Application.

Obtaining Information about a Printer.

Allowing Other Program Interactions while Printing.

The Abort Function.

The Abort Dialog Function.

A (Slightly) More Complex Abort Function.

Printing a Document.

Using Custom Dialog Templates and Hook Functions.

Using a Custom Dialog Templates.

Using a Hook Function.

A General Printing DLL.

The Goals of the Print DLL.

The Input Structure.

The Query Function.

Writing the PRINTIT.DLL Callbacks.

The FormatLine Callback.

The PrintIt Code.

The doPrintIt Function.

The checkFilter Function.

The printLoop Function.

The doHeading Function.

The startPrint Function.

Using an External Abort Dialog Template and Hook Function.

Calling doPrintIt with a Custom Dialog and Hook.

The Page Setup Dialog.

Page Setup Custom Painting Hook.

The Print Explorer.


Memory Management.

Dynamic Memory Allocation-The Simple Approach.

Some Details about Simple Memory Allocation.

Fixed, Moveable, and Discardable Memory Blocks.

Managing Memory Blocks Using the Global- Functions.

Allocating a Fixed Memory Block.

Allocating a Moveable Memory Block.

Allocating a Discardable Global Memory Block.

Allocating a Shareable Memory Block.

Locking and Unlocking Memory Blocks.

Reallocating a Memory Block.

Freeing a Memory Block.

Other Default Heap Functions.

Dynamic Memory Allocation-When Performance Matters.

System Memory Organization.

The Local Heap, the Global Heap, and malloc/new .

(Win16 programmers only!).

Supporting Multiple Heaps.

Considerations When Using the Default Heap.

Page Thrashing - Random Access.

Page Thrashing - Sequential Access.

Synchronization Bottlenecks.

Dynamic Heaps.

Heap Serialization.

Locality of Reference.

Reducing Heap Fragmentation.

Using C++.

Thread-Local Storage.

Using Thread-Local Storage.

The thread Attribute.

Sharing Thread-Local Storage.

Thread-Local Storage Summary.

The Heap Explorer.



Further Reading.


What Is a Font?

Types of Windows Fonts.

Raster Fonts.

Stroke or Vector Fonts.

TrueType Fonts.

Font Resources.

Device Fonts.

Using a Stock Font.

Enumerating Fonts.

Defining a Logical Font.

The LOGFONT Structure.

The Font-matching Scheme.

Getting Information About a Font.


TrueType and ABC Widths.

Pair Kerning.

Track Kerning.

The Font Explorer.

Reading the Font Explorer Display.

Some Font Explorer Application Tips.

Kerning Explorer Anomalies.

Well-behaved Fonts.

Further Reading.


Dynamic Link Libraries.

A Special Note to Win16 Programmers.

What Is a Dynamic Link Library?

Static and Dynamic Linking.

Benefits of Using DLLs.

Constraints Unique to a DLL.

The Stack.

Static Data.

The DllEntryPoint Function.

A DLL Module Definition File.

Importing Symbols.

Importing Data.

Summary of Export Techniques.

Exploring DLL Techniques.

A DLL Requiring No Initialization.

A DLL Requiring Initialization/Finalization.

A Simple Localization Function Library.

A DLL Containing Dialog Resources.

A Resource-only DLL Containing Strings and Other Resources.

DLLs with User-defined Resources.

A DLL That Uses the C Runtime System.

A DLL That Provides Thread-Local Support.

A DLL That Uses a Shared Data Segment.

The Wineyes Example DLL Module: Hook Support.

System Hook Function Types.

The Wineyes Application Module.

Further Reading.


The Multiple Document Interface.

The Behavior of an MDI Application.

The Basic Steps to Creating an MDI Application.

Creating the Frame Window.

Creating the Client Window.

Creating a Child Window.

MDI Client Window Messages.

The MDI Example Program.

Program Initialization.

The MDI Application Message Loop.

The Frame Window Function.

The MDI Child Window Functions.

Embedding an Edit Control.

Updating Toolbars.

WM_CTLCOLORxxx Messages.

Non-solid Brushes.

Handling MessageBox Color Changes.

Object-oriented WM_CTLCOLOR.

The CtlColor Explorer.


Further Reading.



Synchronization basics.

What is synchronization?

Simple synchronization problems.

Synchronization Mechanisms.

Correctness doesn't just happen.

Win32 Synchronization Primitives.



Critical Sections.


Waiting for Synchronization.

Waiting for Threads.

Abandoned Mutexes.

Why you must use synchronization primitives.

Using Synchronization Primitives.

Avoiding Synchronization.

Synchronization via Messages.


Thread Creation.

Inter-thread control.

The Synchronization Explorer.

Further Reading.

Appendix A.

Ternary Raster-Operation Codes.

Appendix B.

Message Cracker Summary.

Appendix C.

windowssx.h, commctrl.h, extensions.h, and tchar.h.

windowsx.h, commctrl.h and extensions.h.

The tchar.h file.

Appendix D.

Using #pragma(warning).

Index. 0201634929T04062001

Read More Show Less

Customer Reviews

Average Rating 4
( 1 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Anonymous

    Posted January 15, 2009

    No text was provided for this review.

Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)