HeaderPane
Main
Hide

SftTree/OCX 8.0 - ActiveX Tree Control

Share Link
Print

ListFont Sample (VB6)

This sample illustrates cell fonts.

The source code is located at C:\Program Files (x86)\Softelvdm\SftTree OCX 8.0\Samples\VB6\ListFont\Form1.frm or C:\Program Files\Softelvdm\SftTree OCX 8.0\Samples\VB6\ListFont\Form1.frm (on 32-bit Windows versions).

VERSION 5.00
Object = "{04048830-2BE4-4868-8CDC-B8E6FC7815C5}#7.5#0"; "SftTree_IX86_U_80.ocx"
Begin VB.Form Form1 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Softel vdm, Inc. - ListFont Sample"
   ClientHeight    =   4815
   ClientLeft      =   2610
   ClientTop       =   3795
   ClientWidth     =   6705
   BeginProperty Font 
      Name            =   "Microsoft Sans Serif"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   4815
   ScaleWidth      =   6705
   Begin SftTreeLib80.SftTree SftTree1 
      Height          =   4575
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   4935
      PropVer         =   75
      xcx             =   8705
      xcy             =   8070
      PropFile        =   ""
      PropDesignTime  =   1
      DeletePropFile  =   0
      IntVal          =   55
      xBfStyle1       =   64044624
      xBfStyle2       =   -1501886369
      xBfStyle3       =   -1549153761
      xBfStyle4       =   1280718321
      FlatProperties  =   0
      Appearance      =   1
      AutoRespond     =   1
      BackgroundPicture=   "FORM1.frx":0000
      BackgroundStyle =   0
      BackgroundX     =   0
      BackgroundY     =   0
      BorderStyle     =   0
      ButtonStyle     =   2
      CellEventHandling=   0
      CellEditStyle   =   0
      CellEditLimit   =   0
      ColumnCount     =   2
      CopyItemDataString=   -1
      CustomCode      =   0
      DragImage       =   -842150451
      DragMethod      =   0
      DragType        =   3
      Enabled         =   1
      HandleReturn    =   -842150451
      MouseIcon       =   "FORM1.frx":9A3A
      MousePointer    =   0
      LeftButtonOnly  =   -1
      LeftItemClickOnly=   -1
      OLEDropMode     =   0
      RightToLeft     =   0
      UseThemes       =   -1  'True
      Scrollbars      =   3
      ScrollbarStyle  =   0
      ShowTruncated   =   -1
      VAlignStyle     =   0
      VirtualMode     =   0
      WebLicense      =   ""
      SmoothScroll    =   1
      ButtonAppearance=   8
      MouseOverTransitionEffect=   0
      EdgeVerticalColor=   -1
      EdgeHorizontalColor=   -1
      BeginProperty ItemEditFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Microsoft Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Columns {9EBAA93E-293D-44FA-9989-08F078763A1F} 
         InheritBgColor  =   0
         OpenEnded       =   1
         OpenEnded2      =   1
      EndProperty
      BeginProperty Headers {9EBAA936-293D-44FA-9989-08F078763A1F} 
         Appearance      =   1
         BackColor       =   -2147483633
         ForeColor       =   -2147483630
         GrayedColor     =   -2147483631
         HilightColor    =   -2147483628
         Multiline       =   0
         ShadowColor     =   -2147483632
         Reorderable     =   0
         Resizable       =   1
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Microsoft Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         SortIndicators  =   0
      EndProperty
      BeginProperty Footers {9EBAA956-293D-44FA-9989-08F078763A1F} 
         Appearance      =   0
         BackColor       =   -2147483633
         ForeColor       =   -2147483630
         GrayedColor     =   -2147483631
         HilightColor    =   -2147483628
         Multiline       =   1
         ShadowColor     =   -2147483632
         Reorderable     =   1
         Resizable       =   1
      EndProperty
      BeginProperty Items {9EBAA93C-293D-44FA-9989-08F078763A1F} 
         AutoExpandDragDrop=   1
         AutoExpandHover =   0
         BackColor       =   -2147483643
         BackColorOdd    =   -2147483643
         CalcLimit       =   0
         CalcVisibleOnly =   0
         Cell3D          =   0
         CharSearchColumn=   0
         CharSearchMode  =   1
         DropHighlightColor=   -2147483635
         DropHighlightStyle=   1
         EditNoFocusStyle=   2
         FlybyHighlight  =   1
         ForeColor       =   -2147483640
         ForeColorOdd    =   -2147483640
         GrayedColor     =   -2147483631
         GridHorizontalColor=   -2147483632
         GridStyle       =   5
         GridVerticalColor=   -2147483632
         HilightColor    =   -2147483628
         HorizontalExtentPix=   0
         HorizontalExtent2Pix=   0
         HorizontalOffsetPix=   0
         HorizontalOffset2Pix=   0
         Indentation     =   -1
         ItemImageAlign  =   1
         Lines           =   1
         MaxHeightPix    =   0
         MinHeightPix    =   0
         MultiSelect     =   0
         NoFocusStyle    =   1
         NoSelection     =   0
         RubberbandSelection=   1
         SelectBackColor =   -2147483635
         SelectBackColorNoFocus=   -2147483633
         SelectForeColor =   -2147483634
         SelectForeColorNoFocus=   -2147483630
         ShadowColor     =   -2147483632
         Style           =   1
         ScrollTips      =   1
         SelectionArea   =   1
         SelectStyle     =   3
         ShowFocusRectangle=   1
         ToolTipAlways   =   0
         ToolTipBackColor=   -1
         ToolTipForeColor=   -1
         ToolTipsUseEntireCell=   0
         TopIndex        =   0
         TreeLineColor   =   -2147483627
         TreeLineGrayedColor=   -2147483627
         TreeLineStyle   =   2
         UpdateCurrentExpandCollapse=   0
         OutlineStyle    =   1
         SelectOutlineBorderColor=   -1
         SelectInnerBorderColor=   -1
         SelectInnerFill1=   -1
         SelectInnerFill2=   -1
         SelectHotOutlineBorderColor=   -1
         SelectHotInnerBorderColor=   -1
         SelectHotInnerFill1=   -1
         SelectHotInnerFill2=   -1
         SelectNoFocusOutlineBorderColor=   -1
         SelectNoFocusInnerBorderColor=   -1
         SelectNoFocusInnerFill1=   -1
         SelectNoFocusInnerFill2=   -1
         HotOutlineBorderColor=   -1
         HotInnerBorderColor=   -1
         HotInnerFill1   =   -1
         HotInnerFill2   =   -1
         DropTargetOutlineBorderColor=   -1
         DropTargetInnerBorderColor=   -1
         DropTargetInnerFill1=   -1
         DropTargetInnerFill2=   -1
         DisabledItemsSelectable=   1
         AutoExpandDragDropInterval=   1200
         AutoExpandHoverInterval=   1200
         ToolTipIntervalOn=   200
         ToolTipIntervalOff=   100
      EndProperty
      BeginProperty RowColumnHeader {9EBAA942-293D-44FA-9989-08F078763A1F} 
         Appearance      =   0
         ButtonDown      =   0
         RemainUp        =   1
         Enabled         =   0
         ImageHAlign     =   0
         ImageVAlign     =   0
         TextHAlign      =   0
         TextVAlign      =   0
         Text            =   ""
         ForeColor       =   -2147483630
         BackColor       =   -2147483633
         HilightColor    =   -2147483628
         ShadowColor     =   -2147483632
         GrayedColor     =   -2147483631
         OverrideTheme   =   0
      EndProperty
      BeginProperty RowColumnFooter {9EBAA95A-293D-44FA-9989-08F078763A1F} 
         Appearance      =   1
         ButtonDown      =   0
         RemainUp        =   1
         Enabled         =   1
         ImageHAlign     =   0
         ImageVAlign     =   0
         TextHAlign      =   0
         TextVAlign      =   0
         Text            =   ""
         ForeColor       =   -2147483630
         BackColor       =   -2147483633
         HilightColor    =   -2147483628
         ShadowColor     =   -2147483632
         GrayedColor     =   -2147483631
         OverrideTheme   =   0
      EndProperty
      BeginProperty RowHeaders {9EBAA944-293D-44FA-9989-08F078763A1F} 
         Appearance      =   0
         RemainUp        =   1
         Enabled         =   1
         Lines           =   1
         TextHAlign      =   0
         TextVAlign      =   0
         Object.Width           =   0
         BackColor       =   -2147483633
         ForeColor       =   -2147483630
         GrayedColor     =   -2147483631
         HilightColor    =   -2147483628
         ShadowColor     =   -2147483632
         SelectBackColor =   -2147483633
         SelectForeColor =   -2147483630
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Microsoft Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      EndProperty
      BeginProperty Splitter {9EBAA94A-293D-44FA-9989-08F078763A1F} 
         SplitColumn     =   0
         Object.Visible         =   0
         OffsetPix       =   0
         WidthPix        =   7
      EndProperty
      BeginProperty Column(0) {9EBAA938-293D-44FA-9989-08F078763A1F} 
         BackColor       =   -1
         CellHAlign      =   0
         CellMultiline   =   0
         CellVAlign      =   0
         CellWordWrap    =   0
         ForeColor       =   -1
         Merge           =   1
         MergeInto       =   1
         MinWidth        =   80
         SelectBackColor =   -1
         SelectForeColor =   -1
         ToolTip         =   1
         Object.Width           =   80
         RealPos         =   0
         DispPos         =   0
         BackColorEnd    =   -1
         SelectBackColorEnd=   -1
         ProgressColor   =   -1
         ProgressColorEnd=   -1
         BackColorOrientation=   0
         ProgressColor   =   -1
         ProgressColorEnd=   -1
         ProgressColorOrientation=   0
         ProgressStyle   =   0
      EndProperty
      BeginProperty Header(0) {9EBAA93A-293D-44FA-9989-08F078763A1F} 
         Enabled         =   1
         KeepPosition    =   0
         Locked          =   0
         ImageHAlign     =   0
         ImageVAlign     =   0
         RemainUp        =   1
         Text            =   "Font Sample"
         TextHAlign      =   0
         TextVAlign      =   0
         BackColor       =   -1
         ForeColor       =   -1
         SelectBackColor =   -1
         SelectForeColor =   -1
         BackColorDisabled=   -1
         ForeColorDisabled=   -1
         OverrideTheme   =   0
         Button          =   0
      EndProperty
      BeginProperty Footer(0) {9EBAA958-293D-44FA-9989-08F078763A1F} 
         Enabled         =   1
         KeepPosition    =   0
         ImageHAlign     =   0
         ImageVAlign     =   0
         RemainUp        =   0
         Text            =   ""
         TextHAlign      =   0
         TextVAlign      =   0
         BackColor       =   -1
         ForeColor       =   -1
         SelectBackColor =   -1
         SelectForeColor =   -1
         BackColorDisabled=   -1
         ForeColorDisabled=   -1
         OverrideTheme   =   0
         Button          =   0
      EndProperty
      BeginProperty Column(1) {9EBAA938-293D-44FA-9989-08F078763A1F} 
         BackColor       =   -1
         CellHAlign      =   0
         CellMultiline   =   0
         CellVAlign      =   0
         CellWordWrap    =   0
         ForeColor       =   -1
         Merge           =   1
         MergeInto       =   1
         MinWidth        =   0
         SelectBackColor =   -1
         SelectForeColor =   -1
         ToolTip         =   1
         Object.Width           =   20
         RealPos         =   1
         DispPos         =   1
         BackColorEnd    =   -1
         SelectBackColorEnd=   -1
         ProgressColor   =   -1
         ProgressColorEnd=   -1
         BackColorOrientation=   0
         ProgressColor   =   -1
         ProgressColorEnd=   -1
         ProgressColorOrientation=   0
         ProgressStyle   =   0
      EndProperty
      BeginProperty Header(1) {9EBAA93A-293D-44FA-9989-08F078763A1F} 
         Enabled         =   1
         KeepPosition    =   0
         Locked          =   0
         ImageHAlign     =   0
         ImageVAlign     =   0
         RemainUp        =   1
         Text            =   "Font"
         TextHAlign      =   0
         TextVAlign      =   0
         BackColor       =   -1
         ForeColor       =   -1
         SelectBackColor =   -1
         SelectForeColor =   -1
         BackColorDisabled=   -1
         ForeColorDisabled=   -1
         OverrideTheme   =   0
         Button          =   0
      EndProperty
      BeginProperty Footer(1) {9EBAA958-293D-44FA-9989-08F078763A1F} 
         Enabled         =   1
         KeepPosition    =   0
         ImageHAlign     =   0
         ImageVAlign     =   0
         RemainUp        =   0
         Text            =   ""
         TextHAlign      =   0
         TextVAlign      =   0
         BackColor       =   -1
         ForeColor       =   -1
         SelectBackColor =   -1
         SelectForeColor =   -1
         BackColorDisabled=   -1
         ForeColorDisabled=   -1
         OverrideTheme   =   0
         Button          =   0
      EndProperty
      SavedItemCount  =   0
      SavedColumnCount=   2
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Microsoft Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.CommandButton Command1 
      Cancel          =   -1  'True
      Caption         =   "Close"
      Default         =   -1  'True
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5160
      TabIndex        =   1
      Top             =   120
      Width           =   1455
   End
   Begin VB.Label Label2 
      Caption         =   "Click on the SftTree/OCX control and hit F1 to access online help for SftTree/OCX 8.0"
      BeginProperty Font 
         Name            =   "Microsoft Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2415
      Left            =   5160
      TabIndex        =   2
      Top             =   2280
      Visible         =   0   'False
      Width           =   1455
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit
    
Private Sub Command1_Click()
    Unload Form1
End Sub


Private Sub Form_Load()
    Dim I As Integer, ItemIndex As Integer
    Dim MaxFonts As Integer
    Dim ScreenIndex As Integer, PrinterIndex As Integer
    Dim C As SftTreeCell

    With SftTree1
        ' Mass-Update
        .BulkUpdate = True
        
        ' Add all screen fonts to the tree control
        ScreenIndex = .Items.Add("Screen Fonts")
        .Item(ScreenIndex).Level = 0
        ' display screen fonts
        MaxFonts = Screen.FontCount
        ' limit to 20 fonts
        If MaxFonts > 20 Then MaxFonts = 20
        For I = 0 To MaxFonts - 1
            ' add the item
            ItemIndex = .Items.Add(Screen.Fonts(I))
            .Item(ItemIndex).Level = 1
            ' set the cell name and font in column 0
            Set C = .Cell(ItemIndex, 0)
            C.Font.Name = Screen.Fonts(I)
            ' not bold
            C.Font.Bold = False
            ' 10 pt
            C.Font.Size = 10
            ' set the font name in column 1
            .Cell(ItemIndex, 1).Text = Screen.Fonts(I)
        Next I
        
        ' Add all print fonts to the tree control
        PrinterIndex = .Items.Add("Printer Fonts")
        .Item(PrinterIndex).Level = 0
        ' limit to 20 fonts
        On Error GoTo NoPrinter
        MaxFonts = Printer.FontCount
        If MaxFonts > 20 Then MaxFonts = 20
        On Error GoTo 0
        For I = 0 To MaxFonts - 1
            ' add the item
            ItemIndex = .Items.Add(Printer.Fonts(I))
            .Item(ItemIndex).Level = 1
            ' set the cell name and font in column 0
            Set C = .Cell(ItemIndex, 0)
            C.Font.Name = Screen.Fonts(I)
            ' not bold
            C.Font.Bold = False
            ' 10 pt
            C.Font.Size = 10
            ' set the font name in column 1
            .Cell(ItemIndex, 1).Text = Printer.Fonts(I)
        Next I
        ' Sort fonts
        .Items.SortDependents PrinterIndex, 0, sortSftTreeAscending
NoPrinter:
        ' Sort fonts
        .Items.SortDependents ScreenIndex, 0, sortSftTreeAscending
        
        .Items.Current = 0
        .Item(0).Selected = True
        
        ' End of Mass-Update
        .BulkUpdate = False
        ' make column widths optimal
        .ColumnsObj.MakeOptimal
        ' allow horizontal scrolling
        .Items.RecalcHorizontalExtent
    End With
End Sub

Private Sub SftTree1_ItemDblClick(ByVal ItemIndex As Long, ByVal ColNum As Integer, ByVal AreaType As Integer, ByVal Button As Integer, ByVal Shift As Integer)
    If AreaType = constSftTreeColumnRes Then
        SftTree1.Column(ColNum).MakeOptimal
        SftTree1.Items.RecalcHorizontalExtent
    End If
End Sub

Last Updated 05/24/2026 - (email)
© 2026 Softel vdm, Inc.