(
Most chapters conclude with Further Reading.) Welcome xliii. Tools Required xliii. Typeface conventions xlv. Icons for insertions xlv. 1. 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.
2. 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.
3. 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.
4. 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.
5. 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.
6. 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.
ScrollDC.
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.
7. 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.
8. 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.
Summary.
9. 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.
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.
10. Using Controls: Scroll Bar, Trackbar, Up/Down, and .
Progress Classes.
The SCROLLBAR Class.
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.
11. 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.
The WM_INITDIALOG Message.
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.
The GWL_USERDATA Field.
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.
12. Menus, Accelerators, Icons, String Resources, and MessageTable Resources.
Menus.
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.
The MENUITEMINFO Structure.
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.
Accelerators.
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.
The MESSAGETABLE Resource.
Further Reading.
13. Printing.
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.
14. 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.
Summary.
15. Further Reading.
Fonts.
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.
Kerning.
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.
16. 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.
17. 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.
Summary.
Further Reading.
18. Synchronization.
Synchronization basics.
What is synchronization?
Simple synchronization problems.
Synchronization Mechanisms.
Correctness doesn't just happen.
Win32 Synchronization Primitives.
Semaphores.
Mutexes.
Critical Sections.
Events.
Waiting for Synchronization.
Waiting for Threads.
Abandoned Mutexes.
Why you must use synchronization primitives.
Using Synchronization Primitives.
Avoiding Synchronization.
Synchronization via Messages.
Threads.
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