Hide

SftBox/OCX 5.0 - Combo Box Control

Display
Print

SftBoxItems.AddFontNames Method

Adds a list of available fonts.

Syntax

VB.NETCount = object.AddFontNames(ByVal InsertIndex As Integer, ByVal FontStyles As SftBoxFontConstants, ByVal AddPictures As Boolean, ByVal hDCPrinter As Integer) As Integer
VBCount = object.AddFontNames(ByVal InsertIndex As Long, ByVal FontStyles As SftBoxFontConstants, ByVal AddPictures As Boolean, ByVal hDCPrinter As Long) As Long
C#.NETint Count = object.AddFontNames(int InsertIndex, SftBoxFontConstants FontStyles, bool AddPictures, int hDCPrinter);
VC++long Count = object->AddFontNames(long InsertIndex, enum SftBoxFontConstants FontStyles, VARIANT_BOOL AddPictures, long hDCPrinter);
CHRESULT object->raw_AddFontNames(long InsertIndex, enum SftBoxFontConstants FontStyles, VARIANT_BOOL AddPictures, long hDCPrinter, long* Count);

object

A SftBoxItems object.

InsertIndex

The zero-based index of the position where the new item(s) will be inserted. Specify -1 to add the list of font names at the end of the list.

FontStyles

Defines the desired font styles to be added to the list. Specify one or a combination of the following:

FontStylesValueDescription
fontSftBoxFixed1Add fixed fonts.
fontSftBoxVariable2Add variable fonts.
fontSftBoxTrueType4Add TrueType fonts.
fontSftBoxRaster8Add raster fonts.
fontSftBoxVector16Add vector fonts.
fontSftBoxScreen32Add screen (display) fonts. If this option is given, display fonts will be added even if hDCPrinter describes a printer font.
fontSftBoxAll32767All fonts (all of the above).

AddPictures

Defines whether item pictures are automatically added for raster and TrueType fonts.

BooleanDescription
TrueItem pictures are automatically added for raster and TrueType fonts. The AddFontNames method clears all item pictures in the control before adding the new list of font names.
FalseItem pictures are not added.

hDCPrinter

Specify a valid printer device context handle to list fonts for a printer. Specify 0 to list display fonts (screen fonts only). If a valid printer device context handle is provided, screen fonts are only added if FontStyles includes fontSftBoxScreen.

Count

Returns the number of font names added to the control.

Comments

The AddFontNames method adds a list of available fonts.

The AddFontNames method adds all font names of all available fonts which match the criteria defined using FontStyles as items to the combo box.

Either fontSftBoxFixed or fontSftBoxVariable (or both) must be specified, otherwise no fonts will match the criteria.

The AddFontNames method can be called many times for a single combo box. This way it is possible to show various categories of fonts in the same combo box by using the FontStyles parameter. Item pictures must be set by the application based on the Cell.Data property, as each invocation of AddFontNames clears all existing item pictures.

The Cell.Data property of the cell in column 0 of each item will contain the font type DEVICE_FONTTYPE, RASTER_FONTTYPE or TRUETYPE_FONTTYPE as returned by EnumFontFamProc (see the Windows API documentation).

The drop down portion is automatically hidden when the combo box contents are changed using this method. The DropDown.SuppressOn method can be used to suppress hiding the drop down portion when adding/inserting items.

Examples

VB.NET

    ' add all font information
    UpdateFontNames()
End Sub

Private Sub UpdateFontNames()
    ' add all font names
    fontNames.BulkUpdate = True
    fontNames.Items.Clear()
    fontNames.Items.AddFontNames(-1, SftBoxFontConstants.fontSftBoxAll, True, 0)
    fontNames.Items.Selection = 0
    PerformSort(fontNames, SftBoxSortConstants.sortSftBoxAscending)
    fontNames.BulkUpdate = False
    fontNames.Columns.MakeOptimal(0)
    fontNames.Items.RecalcHorizontalExtent(0)
End Sub

VB6

        SftBoxCtrl.Items.Sort -1, 0, sortSftBoxDescending
    End If
End Sub

Private Sub UpdateFontNames()
    ' add all font names
    FontNames.BulkUpdate = True
    FontNames.Items.Clear
    FontNames.Items.AddFontNames -1, fontSftBoxAll, True, 0
    FontNames.Items.Selection = 0
    PerformSort FontNames
    FontNames.BulkUpdate = False
    FontNames.Columns.MakeOptimal 0
    FontNames.Items.RecalcHorizontalExtent 0
End Sub

C#

    UpdateFontNames();
}

private void UpdateFontNames()
{
    // add all font names
    fontNames.BulkUpdate = true;
    fontNames.Items.Clear();
    fontNames.Items.AddFontNames(-1, SftBoxFontConstants.fontSftBoxAll, true, 0);
    fontNames.Items.Selection = 0;
    PerformSort(fontNames, SftBoxSortConstants.sortSftBoxAscending);
    fontNames.BulkUpdate = false;
    fontNames.Columns.MakeOptimal(0);
    fontNames.Items.RecalcHorizontalExtent(0);
}

C++

void CFontDlgDlg::UpdateFontNames()
{
    // add all font names
    ISftBoxPtr vFontNames = m_FontNames.GetControlUnknown();

    vFontNames->BulkUpdate = VARIANT_TRUE;
    vFontNames->Items->Clear();
    vFontNames->Items->AddFontNames(-1, fontSftBoxAll, VARIANT_TRUE, 0);
    vFontNames->Items->Selection = 0;
    PerformSort(vFontNames, sortSftBoxAscending);
    vFontNames->BulkUpdate = VARIANT_FALSE;
    vFontNames->Columns->MakeOptimal(0);
    vFontNames->Items->RecalcHorizontalExtent(0);

    m_CondHeaders.SetCheck(1);
}

See Also SftBoxItems Object | Object Hierarchy


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.