CHAPTER 20

COMMON DIALOG BOXES.

Dialog boxes are the specialised windows that enable the user to make selections or enter data. Examples are dialog boxes to open or save files, or to search for a word in a page of text.

You can design a custom dialog box by the use of a template, in conjunction with API functions that instruct Windows to create the dialog box in accordance with the template.

There is, however, a set of system standard dialog boxes provided by Windows, which do not require the creation of templates by the programmer, as they already have default, predefined templates provided by the system. These are called 'Common Dialog Boxes', and you can get detailed information about them by searching the Microsoft website online developer's reference.

Custom dialog boxes are beyond the scope of this text, since readers who become familiar with the programming described in this work can easily investigate such further topics for themselves.

There are eight kinds of common dialog box, for the following purposes, the boxes being created by calling the API Functions named in the list on the left:

ChooseColor: Choose a colour from a list of colours
ChooseFont: Select a font from a list of fonts
GetOpenFileName: Select a file to open
GetSaveFileName: Select a file to save

PageSetupDlg: A printer page setup dialog box
FindText: A dialog box to search for text
ReplaceText: A dialog box to replace text.

Everyone will probably have come across each one of these common or standard dialog boxes at one time or another.

All dialog boxes work in a similar way. User choices are returned via a dialog box data structure. Dialog boxes do not, however, actually implement the selected response. This must be done by the program code, which means the programmer will have to write the response code into the program.

Be aware that dialog boxes called within a response to a Windows message will interfere with the current parameters of the message as they were sent to the callback function.

The parameters, 'message', 'wparam', and 'lparam', must therefore be saved before calling the dialog box, and restored after the user closes it, if the program needs to use DefWindowProc for default processing of a message. Dialog boxes may also interfere with the caret, if you have text on the screen, so you should destroy the caret before calling them, using the DestroyCaret API function, and then restore it again when the dialog box is closed.

                  Part I: Part I Introduction
                  Chapter 1: Binary numbers, code, and procedures
                  Chapter 3: Assembly Language
                  Chapter 4: Assembly Language Code example
                  Chapter 5: Macros and HLA
                  Chapter 6: HLA code example
                  Chapter 7: The Windows operating system
                  Chapter 8: Data Structures
                  Chapter 9: How to Create a Windows Program
                  Chapter 10: How to Create an Exe File
                  Chapter 11: Structured Programming and OOP
                  Part II: Part II Introduction
                  Chapter 12: Debugging a Windows Program Code
                  Chapter 13: Painting the Window Client Area
                  Chapter 14: Creating Window Menus
                  Chapter 15: How to Create Toolbars
                  Chapter 16: How to Create Popup Menus
                  Chapter 17: About the Windows Clipboard
                  Chapter 18: How to Create Bitmaps
                  Chapter 19: Icons and the Ico Format
                  Chapter 20: Common Dialog Boxes
                  Chapter 21: Working with Files
                  Chapter 22: Scrollbars and Scrolling
                  Chapter 23: How to Send Data to the Printer
                  Chapter 24: Miscellaneous Topics

© Alen, June 2014
alen@alenspage.net


Material on this page may be reproduced
for personal use only.