Hide

SftBox/OCX 5.0 - Combo Box Control

Display
Print

SftBoxItems.AddFontSizes Method

Adds a list of available font sizes.

Syntax

VB.NETCount = object.AddFontSizes(ByVal FontName As String, ByVal hDCPrinter As Integer) As Integer
VBCount = object.AddFontSizes(ByVal FontName As String, ByVal hDCPrinter As Long) As Long
C#.NETint Count = object.AddFontSizes(string FontName, int hDCPrinter);
VC++long Count = object->AddFontSizes(_bstr_t FontName, long hDCPrinter);
CHRESULT object->raw_AddFontSizes(BSTR FontName, long hDCPrinter, long* Count);

object

A SftBoxItems object.

FontName

The name of the font whose font sizes are to be added to the control.

hDCPrinter

Specify a valid printer device context handle if the font FontName is a printer font. Specify 0 for screen fonts.

Count

Returns the number of font sizes added to the control.

Comments

The AddFontSizes method adds a list of available font sizes.

The AddFontSizes method adds all available font sizes (in points) of the font FontName to the combo box as items. The combo box is cleared first.

Font sizes are added in ascending order.

The Cell.Data property of the cell in column 0 of each item will contain the font size, which could be used for sorting purposes.

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

    fontStyles.Columns.MakeOptimal(0)
    fontStyles.Items.RecalcHorizontalExtent(0)
End Sub

Private Sub UpdateFontSizes()
    ' add all sizes for the current font name
    If fontNames.Items.Selection >= 0 Then
        Dim OldText As String = fontSizes.Edit.Text
        fontSizes.Items.AddFontSizes(fontNames.get_Cell(fontNames.Items.Selection, 0).Text, 0)
        Dim index As Integer = fontSizes.Items.Find(OldText, 0, 0, False, True, True)
        If index < 0 Then index = 0
        fontSizes.Items.Selection = index
    Else
        fontSizes.Items.Clear()
    End If
    PerformSort(fontSizes, SftBoxSortConstants.sortSftBoxAscending)

VB6

    End If
End Sub

Private Sub UpdateSizes()
    Dim OldText As String, Index As Long
    ' add all sizes for the current font name
    If FontNames.Items.Selection >= 0 Then
        OldText = FontSizes.Edit.Text
        FontSizes.Items.AddFontSizes FontNames.Cell(FontNames.Items.Selection, 0).Text, 0
        Index = FontSizes.Items.Find(OldText, 0, 0, False, True, True)
        If Index < 0 Then Index = 0
        FontSizes.Items.Selection = Index
    Else
        FontSizes.Items.Clear
    End If
    PerformCellValueSort FontSizes

C#

    fontStyles.Items.RecalcHorizontalExtent(0);
}

private void UpdateFontSizes()
{
    // add all sizes for the current font name
    if (fontNames.Items.Selection >= 0) {
        string OldText = fontSizes.Edit.Text;
        fontSizes.Items.AddFontSizes(fontNames.get_Cell(fontNames.Items.Selection,0).Text, 0);
        int index = fontSizes.Items.Find(OldText, 0, 0, false, true, true);
        if (index < 0) index = 0;
        fontSizes.Items.Selection = index;
    } else
        fontSizes.Items.Clear();
    PerformSort(fontSizes, SftBoxSortConstants.sortSftBoxAscending);
    fontSizes.Columns.MakeOptimal(0);

C++

void CFontDlgDlg::UpdateFontSizes()
{
    // add all sizes for the current font name
    ISftBoxPtr vFontNames = m_FontNames.GetControlUnknown();
    ISftBoxPtr vFontSizes = m_FontSizes.GetControlUnknown();

    if (vFontNames->Items->Selection >= 0) {
        CString OldText((LPCTSTR) vFontSizes->Edit->Text);
        vFontSizes->Items->AddFontSizes(vFontNames->Cell[vFontNames->Items->Selection][0]->Text, 0);
        long index;
        vFontSizes->Items->raw_Find((_bstr_t)OldText, 0, 0, VARIANT_FALSE, VARIANT_TRUE, VARIANT_TRUE, &index);
        if (index < 0) index = 0;
        vFontSizes->Items->Selection = index;
    } else
        vFontSizes->Items->Clear();
    PerformSortSize(vFontSizes, sortSftBoxAscending);

See Also SftBoxItems Object | Object Hierarchy


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