12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

VCL Components<br />

The File Open and File Save Dialog Boxes<br />

The File Open and File Save dialog boxes have several properties <strong>in</strong> common. File Open is<br />

used when you want to allow the user to open a file <strong>in</strong> your application (see Figure 8.8). It<br />

is encapsulated <strong>in</strong> the OpenDialog component. You use the File Save dialog box when gett<strong>in</strong>g<br />

a filename from the user <strong>in</strong> order to save a file. It is also used as the Save As dialog box. The<br />

File Save dialog box is encapsulated by the SaveDialog component.<br />

Figure 8.8.<br />

A typical File Open<br />

dialog box.<br />

NOTE<br />

The File dialog boxes are fairly easy to use <strong>in</strong> their most basic form. They do have a few<br />

features, however, that need to be expla<strong>in</strong>ed <strong>in</strong> order for you to get the full benefit of us<strong>in</strong>g<br />

them. The follow<strong>in</strong>g sections exam<strong>in</strong>e the properties that are specific to the File dialog boxes.<br />

The OpenDialog and SaveDialog components merely retrieve a filename<br />

from the user. It is up to the programmer to write code that actually<br />

does someth<strong>in</strong>g with the filename.<br />

The DefaultExt Property<br />

Use the DefaultExt property to set the default extension that the dialog box will use. The<br />

default extension is the extension that will automatically be appended to the filename if the<br />

user does not supply an extension.<br />

The FileName Property<br />

The FileName property is the most obvious of the File dialog box properties; it holds the text<br />

of the file that the user chooses. Set this property before call<strong>in</strong>g the dialog box if you want<br />

a filename to show <strong>in</strong> the edit portion of the File dialog box when it is <strong>in</strong>itially displayed. After<br />

the user clicks OK to close the dialog box, this property will conta<strong>in</strong> the full path and filename<br />

of the file chosen.<br />

309<br />

8

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!