Last updated:
1. September 2008

User Interface Programming

(Start main menu) Home ­ Articles ­ Book ­ Resources (End main menu)

Table of Contents

(Start sub-menu)

Table of Contents


Sample Chapter




My blog »

(End sub-menu)


Who Should Read This Book?

The Source Code


Legal Matters

Section I Background

1 The Road Ahead

Destination: The App­li­ca­t­ion

Roadbed: The Target Platform

Vehicle: The Programming Language

2 Designing for Users

Polite App­li­ca­t­ions


Focused Design

The Windows Logo Program

Usability Testing

The Unified File Model

3 Designing for Programmers

Programming Guiding Principles

Getting Your Priorities Straight

Global Variables Considered Harmful

Assert Your Sanity

Constantly on Guard

Use Destruction Constructively

Programming Defensively

Is Windows Object-Oriented?

4 The Mechanics of Subclassing

Subclassing Defined

Instance subclassing

Global Subclassing

Class Cloning

Gen­e­ral Mechanism for Global Subclassing

Gen­e­ral Mechanism for Instance Subclassing

The Window Class: Wrapping the HWND

Section II Foreground

5 The Bare Bones

The Major Organs

The Heart

The Editor Class

The Document Class

The AbstractEditWnd Class

Of Strings and Pathnames

6 Exceptions

Return Codes


Two-Stage Construction

Global Object Constructor Exceptions

The TextEdit Exception Classes

Converting Allocation Failures to Exceptions

Recovering from Errors

Structured Exception Handling and C++ Exceptions

7 Off the Launch pad

Click, Drag and Drop

Shell Integration

GUI Summary

The Console Connection

File Not Found

Read Only

Other Anomalies

Command-line Piping

Drag and Drop Revisited

Additional Switches

Accessing the Command Line

8 Child Windows

Window Creation

The Toolbar

The Status Bar

9 The Main Window

Handling WM_COMMAND Messages

The Clipboard User Interface

Persistence in the Main Window

Drag and Drop

Menu Management

Communication Bet­ween TextEdit Instances

Changing User Settings


The Editor Connection

10 Customization and Persistence

Customizing Windows

Retrieving the Font

Customizing TextEdit

Long-Term Memory

The Registry Interface



Food for Persistent Thought

11 Wait a Moment

Changing the Cursor Image

12 File I/O

Drive Type


Opening Files

Reading and Writing Files

Copying the Original



Conflict of Interest

13 About Dialogs

What is a Dia­log Box, Anyway?

The Dia­log Class

The About Box

The Options Dia­log

Enter with Care

14 File Management

File Properties

Deleting Files

The Open File Dia­log

15 Search and Replace

Default But­ton Handling

Initializing the Dia­log


Text Not Found

The Relationship bet­ween Dia­log and Main Window

Replacing Text

16 Printing


The Page Setup Dia­log

The Print Dia­log

Text Rendering and Pagination

17 Changing Fonts

Subclassing the Font Common Dia­log

18 Going Abroad

Resource Files

Formatting Messages

Formatting Numbers

Formatting Dates, and Money, and…

19 Meanwhile, in the Background

Threads in TextEdit

Starting Threads

Communication Bet­ween Threads

20 Setup, and Down Again



Mea Culpa

21 The End of the Road

Appendix A TextEdit Command Index

Appendix B Bibliography and Recommended Reading


What’s on the CD-ROM?

(Start bottom menu)

Win­dows De­vel­oper Maga­zineR&D BooksCMP Books Petter Hesselberg

(End bottom menu)

Programming Industrial Strength Windows (cover)

R&D Books

View larger image

TextEdit on CodePlex
PISW on CodePlex

Download source code (archive)

CMP Books Logo