Sams Teach Yourself Visual Basic 6 in 24 Hours

Sams Teach Yourself Visual Basic 6 in 24 Hours

By Greg Perry

Generating Common Dialog Boxes

When you add a Common Dialog Box control to your toolbox and then double-click the control to add a dialog box to your Form window, Visual Basic offers an extra Properties window property, Custom, that can be used to set multiple properties. This special Property Pages dialog box is reached by right-clicking the Common Dialog Box icon and selecting Properties.

Figure 12.9 shows the tabbed Property Pages dialog box that appears when you click the Custom property. You'll see tabs across the top that display properties sheets for Open/Save As, Color, Font, Print, and Help dialog boxes. The properties sheets don't offer all properties, but they do simplify entering the most common properties for each kind of dialog box.

12fig09.gif

Figure 12.9 The Custom property makes entering design-time common dialog box properties simple.

You use the Custom properties sheets to set as many properties at design time as you can. Your code can set the rest. For example, if you prefer to display text using the Arial font that appears on most Windows systems, you can type Arial in the Custom Font properties sheet for the FontName property. When the user runs the application and displays the Font dialog box, Arial will be selected. Of course, the user might change the selection, and if Arial doesn't exist on the user's system, the Font dialog box may make a different font the default font. Therefore, your code must check the dialog box's FontName property when the dialog box returns control to your application to see if the user selected a different font.

Share ThisShare This

Informit Network