Change Font Attributes Sample
File: ...\Samples\Solution\Toolbars\Format.scx
This example illustrates using a toolbar to set FontName, FontSize, FontBold, FontItalic, ForeColor, and BackColor properties of controls on a form.
The toolbar is the tbrEditing class in ...\Samples\Classes\Samples.vcx. The nAppliesTo property of the class specifies whether to set the properties of the currently selected control, all text boxes and edit boxes on the form, or all controls on the form. The code in the InteractiveChange or Click event of the toolbar controls sets the properties. For example, the following code is associated with the Click event of cmdBold:
IF TYPE("_SCREEN.ActiveForm") = 'O'
oForm = _SCREEN.ActiveForm
ELSE
RETURN
ENDIF
DO CASE
CASE THIS.Parent.nAppliesTo = 1 && Current Control
oForm.ActiveControl.FontBold = THIS.Value
CASE THIS.Parent.nAppliesTo = 2 && Text and edit boxes
oForm.SetAll('FontBold', THIS.Value, 'TEXTBOX')
oForm.SetAll('FontBold', THIS.Value, 'EDITBOX')
CASE THIS.Parent.nAppliesTo = 3 && All Controls
oForm.SetAll('FontBold', THIS.Value)
ENDCASE
The only code in the form is associated with the GotFocus event of the controls. Each GotFocus event contains the following line of code:
THISFORMSET.tbrEditing.Refresh(THIS)
The Refresh method of tbrEditing sets the values of the editing controls of the toolbar to reflect the current settings of the object whose reference is passed in as a parameter.
See Also
Tasks
Reference
Font Combobox Foundation Class
Fontsize Combobox Foundation Class