Contents
Font Dialog  Sample Help

Sample Description: Font Dialog

Points of Interest

Adding a Font Dialog to your Application

Posting the Font Dialog

Selecting a Font

Applying a Selected Color

Control

Font Dialog

For Help on Help, Press F1


Font Dialog

There are several fonts that come standard with Windows and can be used throughout the Windows environment. Depending on your needs, you can also add to this set by buying additional fonts.

The Font dialog box contains controls that make it possible for a user to select a font, a font style (such as bold, italic, or regular), a point size, and an effect (such as underline, strikeout, or a text color).

To run the Font Dialog sample:

1.	Click on the SetFont button. The Font Dialog will automatically be displayed on the screen.

2.	Click the desired font characteristics on the Font Dialog. A sample text string will visually display the desired font characteristics.

3.	To apply the currently selected font characteristics to the sample font, click the OK. The font characteristics that you have chosen will be displayed at the bottom of the sample form.


Adding a Font Dialog to your Application

A font dialog can easily be added to your application for selecting fonts. This is accomplished by embedding a FontDialog object as an object in your form's property list. In the sample shown, the FontDialog was embedded and given the name "FontPanel."

When added to an application, the user can select one of the fonts presented in the Font Dialog. Once a font has been chosen, the font characteristics can be applied through program code to change the fonts of various controls in the application form.


Posting the Font Dialog

To display the Font Dialog, you should set various characteristics or "display" properties to True or False, depending on whether you want these characteristic options available in the Font Dialog. Below are a list of possible options:

Option	Description

AllowEffects	Provides Strikethru , Underline,  and Color attributes.

AllowFaceSelect	Displays a pre-selected face name above the face name list.

AllowSizeSelect	Displays a pre-selected size above the size list.

AllowStyleSelect	Displays a pre-selected style above the style list.

OnlyAnsi	Option to display only ANSI supported fonts.

OnlyFixedPitch	Option to display only Fixed-Pitched fonts.

OnlyTrueType	Option to display only True-Type fonts.

Limit Size	Provides the capability for selecting a specific font size.

In addition, you may wish to place an informative label in the title area of the Font Dialog, such as "Please Select Font." This can be done by setting the FontDialog Title property. For example:  FontPanel.Title = "Please select font"

To actually post the Font Dialog, you need only run the dialog's Execute method. For example:  FontPanel.Execute

As you examine the code found in the btnSetFont_Click method, you will see that once the Execute method is issued, your program is temporarily suspended until either the OK or Cancel button on the FontDialog are clicked.


Selecting a Font

Once a Font Dialog is posted, you may select one of the available fonts displayed in the Font list. In addition, you may click on various font characteristics that also may be displayed in the Font Dialog.

To select a font, simply click on the desired font and font characteristics, then click OK. Click the Cancel button to abort the font selection operation.


Applying a Selected Color

Once a font has been selected from the Font Dialog, the corresponding font properties for the FontPanel object in the Property editor are automatically updated to display the user's selected options. At this point, it is up to your program code to apply these properties by setting a corresponding font property of another object. In our example, the control lblTest will receive the settings of the various font properties.