SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftPrintPreview/DLL 2.0 - Print Preview Control (discontinued)
SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftDirectory 3.5 - File/Folder Control (discontinued)
SftMask/OCX 7.0 - Masked Edit Control
SftOptions 1.0 - Registry/INI Control (discontinued)
SftPrintPreview/OCX 1.0 - Print Preview Control (discontinued)
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTabs/NET 6.0 - Tab Control (discontinued)
SftTree/NET 2.0 - Tree Control
Adds a list of available font styles.
VB.NET | Count = object.AddFontStyles(ByVal FontName As String, ByVal hDCPrinter As Integer, ByVal StylesText As String, ByVal ItalicText As String) As Integer |
VB | Count = object.AddFontStyles(ByVal FontName As String, ByVal hDCPrinter As Long, ByVal StylesText As String, ByVal ItalicText As String) As Long |
C#.NET | int Count = object.AddFontStyles(string FontName, int hDCPrinter, string StylesText, string ItalicText); |
VC++ | long Count = object->AddFontStyles(_bstr_t FontName, long hDCPrinter, _bstr_t StylesText, _bstr_t ItalicText); |
C | HRESULT object->raw_AddFontStyles(BSTR FontName, long hDCPrinter, BSTR StylesText, BSTR ItalicText, long* Count); |
object
FontName
The name of the font whose available styles 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.
StylesText
The font style text for each possible font style. Supply comma-delimited styles for each of the following font weights. The font weights are listed in ascending weight, lightest to darkest:
Font Weight | Description |
---|---|
FW_THIN | very light font |
FW_EXTRALIGHT | |
FW_LIGHT | |
FW_NORMAL | normal font |
FW_MEDIUM | |
FW_SEMIBOLD | |
FW_BOLD | bold font |
FW_EXTRABOLD | |
FW_HEAVY | very heavy font |
As fonts are enumerated by the control, the font weight returned by Windows is replaced by the substring supplied in StylesText for the corresponding weight. The font weights are documented in the Windows API reference, see the LOGFONT structure. If an empty string (0, null, NULL) is specified for this parameter, the default string "Normal,Normal,Normal,Normal,Bold,Bold,Bold,Bold,Bold" is used.
ItalicText
The string appended to the font style if a font has the italic attribute. If an empty string (0, null, NULL) is specified for this parameter, the default string ", Italic" is used.
Count
Returns the number of font styles added to the control.
The AddFontStyles method adds a list of available font styles.
The AddFontStyles method adds all available font styles of the font FontName to the combo box as items. The combo box is cleared first.
Font styles are added in ascending order, according to the font's weight.
The Cell.Data property of the cell in column 0 of each item will contain the font weight. The high order bit is set if the font style is italic.
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.
fontNames.Columns.MakeOptimal(0) fontNames.Items.RecalcHorizontalExtent(0) End Sub Private Sub UpdateFontStyles() ' add all styles for the current font name If fontNames.Items.Selection >= 0 Then Dim OldText As String = fontStyles.Edit.Text fontStyles.Items.AddFontStyles(fontNames.get_Cell(fontNames.Items.Selection, 0).Text, 0, "", "") Dim index As Integer = fontStyles.Items.Find(OldText, 0, 0, False, True, True) If index < 0 Then index = 0 fontStyles.Items.Selection = index Else fontStyles.Items.Clear() End If PerformSort(fontStyles, SftBoxSortConstants.sortSftBoxAscending)
End If End Sub Private Sub UpdateStyles() Dim OldText As String, Index As Long ' add all styles for the current font name If FontNames.Items.Selection >= 0 Then OldText = FontStyles.Edit.Text FontStyles.Items.AddFontStyles FontNames.Cell(FontNames.Items.Selection, 0).Text, 0, "", "" Index = FontStyles.Items.Find(OldText, 0, 0, False, True, True) If Index < 0 Then Index = 0 FontStyles.Items.Selection = Index Else FontStyles.Items.Clear End If PerformSort FontStyles
fontNames.Items.RecalcHorizontalExtent(0); } private void UpdateFontStyles() { // add all styles for the current font name if (fontNames.Items.Selection >= 0) { string OldText = fontStyles.Edit.Text; fontStyles.Items.AddFontStyles(fontNames.get_Cell(fontNames.Items.Selection,0).Text, 0, "", ""); int index = fontStyles.Items.Find(OldText, 0, 0, false, true, true); if (index < 0) index = 0; fontStyles.Items.Selection = index; } else fontStyles.Items.Clear(); PerformSort(fontStyles, SftBoxSortConstants.sortSftBoxAscending); fontStyles.Columns.MakeOptimal(0);
void CFontDlgDlg::UpdateFontStyles() { // add all styles for the current font name ISftBoxPtr vFontNames = m_FontNames.GetControlUnknown(); ISftBoxPtr vFontStyles = m_FontStyles.GetControlUnknown(); if (vFontNames->Items->Selection >= 0) { CString OldText((LPCTSTR) vFontStyles->Edit->Text); vFontStyles->Items->AddFontStyles(vFontNames->Cell[vFontNames->Items->Selection][0]->Text, 0, "", ""); long index; vFontStyles->Items->raw_Find((_bstr_t)OldText, 0, 0, VARIANT_FALSE, VARIANT_TRUE, VARIANT_TRUE, &index); if (index < 0) index = 0; vFontStyles->Items->Selection = index; } else vFontStyles->Items->Clear(); PerformSort(vFontStyles, sortSftBoxAscending);
See Also SftBoxItems Object | Object Hierarchy