Chapter 5. Subclassing the Windows Common Dialog Boxes

This chapter will focus on subclassing, but in a more specific area. In this chapter I will show you how to subclass the Windows common dialogs. Subclassing is the term commonly used to describe what we will be doing in this chapter, but as we shall see, the term might not be entirely accurate. The Open, Save As, Print, Page Setup, Print Property Sheet, Font, Help, Find, Replace, and Color dialogs are all part of the standard dialogs that ship with the Windows operating system. These dialogs are found in comdlg32.dll. Most of them also are encapsulated in an ActiveX control called the Common Dialog control.

Visual Basic (VB) can use either comdlg32.dll or the Common Dialog control to create and manipulate these dialog boxes. Using the Common Dialog control hides much of the complexity of using the common dialogs. However, if you want to subclass a common dialog, you have to use comdlg32.dll directly. Throughout this chapter I will be using comdlg32.dll to create and manipulate the common dialog boxes that we will subclass.

You might wonder why you would want to subclass one of the Windows common dialogs, especially because modifying a common dialog is usually the exception rather than the rule. But sometimes modifying a common dialog box is a more efficient approach to solving a problem, especially when the developer needs more control over a user’s interaction with a common dialog box. Instead of creating a whole new Save ...

Get Subclassing and Hooking with Visual Basic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.