The Open Picture Dialog Box



You can use the Open File dialog control to open a picture, but you would have to configure wholly, almost from scratch. To give you a convenient ways with a ready made object to open pictures, the VCL provides the Open Picture dialog box. The Open Picture dialog box is flexible as it spares you the hassle of setting such aspects as the file filters. Furthermore, unlike the Open file dialog box, the Open Picture dialog box gives the ability to preview a picture before opening it.

Creating an Open Picture Dialog Box

The Open Picture dialog box is an object of type TOpenPictureDialog. This class is derived from the TOpenDialog class but it is defined in the ExtDlgs.hpp header file.

To visually add support to open a picture in your application, in the Dialogs section of the Tool Palette, click TOpenPictureDialog Open Picture Dialog and click its container. In the same way, to programmatically create an Open Picture dialog box, declare a variable of type TOpenPictureDialog. In the constructor, specify its owner.

Characteristics of an Open Picture Dialog Box

Because the TOpenPictureDialog class is derived from the TOpenDialog class, that's where it gets all its primary functionality. These include the title for the dialog box (the Title property), the filter to restrict the types of files (the Filter property), the default file extension (the DefaultExt property), the initial directory (the InitialDir property), and the ability to display the dialog box (the Execute() method).

There are two main differences between a TOpenDialog and a TOpenPictureDialog controls. The latter provides an already-made filter configured for all popular picture types. The biggest visual difference is that the Open Picture dialog box is equipped with an area that previews the picture.


Home Copyright © 2010-2011 FunctionX, Inc.