Working with IVBFontDialog Parts

The following tasks are associated with using an IVBFontDialog* part in visual composition. Tasks that are common to many parts are described in related topics.

Defining the title
To define a title for the dialog, set the Title property in the IVBFontDialog* property sheet. Enter the title in the value column.

Filtering the list
To list only fonts in one font family, such as Helvetica or Courier, set the Initial font family property in the IVBFileDialog* property sheet. Enter the family name in the value column. Leave this field empty to list all available fonts.

Defining preview text
To provide preview text to show font appearance in the dialog, set the Preview text property in the IVBFontDialog* property sheet. Enter the text in the value column.

Assigning ownership
An IVBFontDialog* part serves the frame window that owns it. If you have only one frame window in a composite part, the IVBFontDialog* part is automatically owned by that frame window. To provide a font dialog for an additional frame window, do the following:

Opening the dialog to set a font
To set a font for a window or control, do the following:
  1. Connect an event to the IVBFontDialog* setFontFromWindowModally action.

  2. Connect the this attribute of the target part to the target parameter of the event-to-setFontFromWindowModally connection.

When the font dialog is opened, it shows the current font for the part. When the user clicks the OK button, the dialog applies the selected font to the part and closes.

Opening the dialog to return a font
To get a font selection from a modal dialog, do the following:
  1. Connect an event to the IVBFontDialog* showModally action.

  2. Connect the IVBFontDialog* font attribute to a target IFont* attribute.

When the user clicks the OK button, the selected font is returned to the target attribute and the dialog closes.

Calling a member function for a font operation
To call a member function for the font operation, do the following:
  1. Connect the IVBFontDialog* pressedOkEvent feature to the free-form surface.
  2. Select All Features on the connection menu.
  3. Enter the signature of a member function to perform the operation.
  4. Connect the IVBFontDialog* font attribute to a font parameter on the connection to the member function.

Running custom logic for a font operation
To run custom logic for the font operation, do the following:
  1. Connect the IVBFontDialog* pressedOkEvent feature to the free-form surface.
  2. Select Custom logic on the connection menu.
  3. Enter C++ code to perform the operation. To access the font selection in your custom logic, select Source. Enter the get member function of the font attribute after the source pointer inserted into your code. This is the resulting code segment:
      source->font()
    


Related procedures
Setting Part Font Properties
Working with VisualAge User Interface Parts

Related references
IVBFontDialog
Property Settings -- IVBFontDialog
Portability -- IVBFontDialog