19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The Flags property influences certain features of the dialog box <strong>and</strong> should be set prior<br />

to setting the Show method. A complete discussion of the Flags property would be too great<br />

a digression. For our purposes, we will be well served by always setting the Flags property<br />

to 3 with the statement<br />

dlgBox.Flags = 3<br />

After selections are made from a common dialog box <strong>and</strong> the OK button is clicked, the values<br />

of the selections are stored in properties such as FileName, Color, FontName, FontItalic,<br />

FontSize <strong>and</strong> Copies. For instance, the following event procedure specifies the font for the<br />

contents of a text box.<br />

Private Sub cmdButton_Click()<br />

dlgFont.Flags = 3<br />

dlgFont.ShowFont ‘invoke Font common dialog box<br />

‘Select Font, Font style, <strong>and</strong> Size <strong>and</strong> then click on OK<br />

txtBox.Font.Name = dlgFont.FontName<br />

txtBox.Font.Bold = dlgFont.FontBold<br />

txtBox.Font.Italic = dlgFont.FontItalic<br />

txtBox.Font.Size = dlgFont.FontSize<br />

End Sub<br />

Table 10.2 gives the principal properties whose setting are garnered from the common<br />

dialog boxes.<br />

TABLE 10.2<br />

Principal Properties of the Common Dialog Boxes<br />

Type of Common<br />

Dialog Box Principal Properties<br />

Open FileName<br />

Save As FileName<br />

Color Color<br />

Font FontName, FontSize, FontBold, FontItalic<br />

Print Copies, FromPage, ToPage<br />

With Open <strong>and</strong> Save As common dialog boxes, a property is needed to specify what<br />

types of files should be displayed. A statement of the form<br />

dlgFile.Filter = “dscrpt1|filter1|dscrpt2|filter2|dscrpt3|filter3“<br />

provides verbal descriptions for the Type box <strong>and</strong> strings using wildcard characters (filters) to<br />

identify the files. A specific statement might be<br />

dlgFile.Filter = “Text Files|*.TXT|FRM Files|*.FRM|All Files|*.*”<br />

After the filter property is set, the FilterIndex property can be used to set the default filter. For<br />

instance, if the preceding statement is followed with<br />

dlgFile.FilterIndex = 1<br />

the default will be the first pair of filter items. That is, when the dialog box pops up, the Files<br />

of type box will display Text Files, <strong>and</strong> the large box will show only files with the extension<br />

TXT.<br />

COMMENT<br />

1. In the Properties window of a FlexGrid control, one setting of the GridLines<br />

property is “0 – flexGridNone.” In code, this setting can be invoked with either<br />

Five Additional Objects 315

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

Saved successfully!

Ooh no, something went wrong!