HeaderPane
Main
Hide

SftTree/OCX 8.0 - ActiveX Tree Control

Share Link
Print

Pictures Sample (VB6)

This sample illustrates using bitmaps, images, imagelists, checkboxes, radiobuttons, color samples, progress bars and more.

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

VERSION 5.00
Object = "{04048830-2BE4-4868-8CDC-B8E6FC7815C5}#7.5#0"; "SftTree_IX86_U_80.ocx"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form1 
   Caption         =   "Softel vdm, Inc. - Pictures Sample"
   ClientHeight    =   7365
   ClientLeft      =   165
   ClientTop       =   810
   ClientWidth     =   8430
   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"
   ScaleHeight     =   7365
   ScaleWidth      =   8430
   StartUpPosition =   3  'Windows Default
   Begin SftTreeLib80.SftTree SftTree1 
      Height          =   5175
      Left            =   240
      TabIndex        =   0
      Top             =   120
      Width           =   7215
      PropVer         =   75
      xcx             =   12726
      xcy             =   9128
      PropFile        =   ""
      PropDesignTime  =   1
      DeletePropFile  =   0
      IntVal          =   55
      xBfStyle1       =   64044624
      xBfStyle2       =   -1014846369
      xBfStyle3       =   -1062113761
      xBfStyle4       =   793678321
      FlatProperties  =   0
      Appearance      =   1
      AutoRespond     =   -842150451
      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      =   1
      DragType        =   3
      Enabled         =   1
      HandleReturn    =   -842150451
      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=   -1
      MouseOverTransitionEffect=   4
      BeginProperty ButtonExpanded {980702E2-0AB6-41B1-9B85-F8755A697255} 
         Object.Height          =   0
         Object.Width           =   0
         Appearance      =   -1
         FrameColor      =   -1
         SampleColor     =   -1
         Image           =   "Form1.frx":0000
      EndProperty
      BeginProperty ButtonCollapsed {980702E2-0AB6-41B1-9B85-F8755A697255} 
         Object.Height          =   0
         Object.Width           =   0
         Appearance      =   -1
         FrameColor      =   -1
         SampleColor     =   -1
         Image           =   "Form1.frx":01EB
      EndProperty
      BeginProperty ButtonExpandedHot {980702E2-0AB6-41B1-9B85-F8755A697255} 
         Object.Height          =   0
         Object.Width           =   0
         Appearance      =   -1
         FrameColor      =   -1
         SampleColor     =   -1
         Image           =   "Form1.frx":03DE
      EndProperty
      BeginProperty ButtonCollapsedHot {980702E2-0AB6-41B1-9B85-F8755A697255} 
         Object.Height          =   0
         Object.Width           =   0
         Appearance      =   -1
         FrameColor      =   -1
         SampleColor     =   -1
         Image           =   "Form1.frx":05D9
      EndProperty
      EdgeVerticalColor=   -1
      EdgeHorizontalColor=   -1
      BeginProperty ItemEditFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS 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  =   1
         OpenEnded       =   0
         OpenEnded2      =   1
      EndProperty
      BeginProperty Headers {9EBAA936-293D-44FA-9989-08F078763A1F} 
         Appearance      =   1
         BackColor       =   -2147483633
         ForeColor       =   -2147483630
         GrayedColor     =   -2147483631
         HilightColor    =   -2147483628
         Multiline       =   1
         ShadowColor     =   -2147483632
         Reorderable     =   1
         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=   -1
         CharSearchMode  =   1
         DropHighlightColor=   -2147483635
         DropHighlightStyle=   1
         EditNoFocusStyle=   2
         FlybyHighlight  =   1
         ForeColor       =   -2147483640
         ForeColorOdd    =   -2147483640
         GrayedColor     =   -2147483631
         GridHorizontalColor=   -2147483633
         GridStyle       =   6
         GridVerticalColor=   -2147483633
         HilightColor    =   -2147483628
         HorizontalExtentPix=   0
         HorizontalExtent2Pix=   0
         HorizontalOffsetPix=   0
         HorizontalOffset2Pix=   0
         Indentation     =   -1
         ItemImageAlign  =   1
         Lines           =   5
         MaxHeightPix    =   0
         MinHeightPix    =   0
         MultiSelect     =   0
         NoFocusStyle    =   0
         NoSelection     =   0
         RubberbandSelection=   1
         SelectBackColor =   -2147483635
         SelectBackColorNoFocus=   -2147483633
         SelectForeColor =   -2147483634
         SelectForeColorNoFocus=   -2147483630
         ShadowColor     =   -2147483632
         Style           =   1
         ScrollTips      =   1
         SelectionArea   =   1
         SelectStyle     =   0
         ShowFocusRectangle=   1
         ToolTipAlways   =   0
         ToolTipBackColor=   -1
         ToolTipForeColor=   -1
         ToolTipsUseEntireCell=   0
         TopIndex        =   0
         TreeLineColor   =   -2147483631
         TreeLineGrayedColor=   -2147483631
         TreeLineStyle   =   3
         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
         BeginProperty ItemImageExpandable {980702E2-0AB6-41B1-9B85-F8755A697255} 
            Object.Height          =   0
            Object.Width           =   0
            Picture         =   "Form1.frx":07D6
            Appearance      =   -1
            FrameColor      =   -1
            SampleColor     =   -1
         EndProperty
         BeginProperty ItemImageExpanded {980702E2-0AB6-41B1-9B85-F8755A697255} 
            Object.Height          =   0
            Object.Width           =   0
            Picture         =   "Form1.frx":08E8
            Appearance      =   -1
            FrameColor      =   -1
            SampleColor     =   -1
         EndProperty
         BeginProperty ItemImageLeaf {980702E2-0AB6-41B1-9B85-F8755A697255} 
            Object.Height          =   0
            Object.Width           =   0
            Picture         =   "Form1.frx":09FA
            Appearance      =   -1
            FrameColor      =   -1
            SampleColor     =   -1
         EndProperty
      EndProperty
      BeginProperty RowColumnHeader {9EBAA942-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 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      =   3
         RemainUp        =   1
         Enabled         =   1
         Lines           =   1
         TextHAlign      =   0
         TextVAlign      =   0
         Object.Width           =   40
         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   =   1
         CellVAlign      =   0
         CellWordWrap    =   1
         ForeColor       =   -1
         Merge           =   1
         MergeInto       =   1
         MinWidth        =   50
         SelectBackColor =   -1
         SelectForeColor =   -1
         ToolTip         =   1
         Object.Width           =   100
         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     =   2
         ImageVAlign     =   0
         RemainUp        =   1
         Text            =   "Pictures"
         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   =   1
         CellVAlign      =   0
         CellWordWrap    =   1
         ForeColor       =   -1
         Merge           =   1
         MergeInto       =   1
         MinWidth        =   0
         SelectBackColor =   -1
         SelectForeColor =   -1
         ToolTip         =   1
         Object.Width           =   300
         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     =   2
         ImageVAlign     =   0
         RemainUp        =   1
         Text            =   "Description"
         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.Timer Timer1 
      Interval        =   333
      Left            =   7800
      Top             =   4680
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   7680
      Top             =   3480
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   8
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0B0C
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0C1E
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0D30
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0E42
            Key             =   ""
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0F54
            Key             =   ""
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":1066
            Key             =   ""
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":1178
            Key             =   ""
         EndProperty
         BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":128A
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.PictureBox PictureIconSmall 
      Height          =   615
      Left            =   7680
      Picture         =   "Form1.frx":139C
      ScaleHeight     =   555
      ScaleWidth      =   555
      TabIndex        =   5
      Top             =   2760
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.PictureBox PictureIcon 
      Height          =   615
      Left            =   7680
      Picture         =   "Form1.frx":49C26
      ScaleHeight     =   555
      ScaleWidth      =   555
      TabIndex        =   4
      Top             =   2040
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.PictureBox PictureSmallBitmap 
      Height          =   615
      Left            =   7680
      Picture         =   "Form1.frx":4A183
      ScaleHeight     =   555
      ScaleWidth      =   555
      TabIndex        =   3
      Top             =   1320
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.PictureBox PictureLogo 
      BorderStyle     =   0  'None
      Height          =   975
      Left            =   240
      Picture         =   "Form1.frx":4A649
      ScaleHeight     =   975
      ScaleWidth      =   3975
      TabIndex        =   2
      Top             =   5400
      Visible         =   0   'False
      Width           =   3975
   End
   Begin VB.Label Label2 
      Caption         =   "Click on the SftTree/OCX control above and hit F1 to access online help for SftTree/OCX 8.0"
      BeginProperty Font 
         Name            =   "Microsoft Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   360
      TabIndex        =   1
      Top             =   6480
      Visible         =   0   'False
      Width           =   7695
   End
   Begin VB.Menu AppExit 
      Caption         =   "E&xit"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit

Dim SortDirection As Boolean

Private Sub AppExit_Click()
    End
End Sub

Private Sub Form_Resize()
    SftTree1.Move 0, 0, ScaleWidth, ScaleHeight
End Sub

Private Sub CopyImageFromCurrentItem()
    Dim ItemIndex As Integer
    Dim Img As SftPictureObject
    
    ItemIndex = SftTree1.Items.Current
    If ItemIndex < 0 Then Exit Sub
    
    ' don't use images that are too large in the other areas
    Set Img = SftTree1.Cell(ItemIndex, 0).Image
    If Img.ActualHeight <= 20 And Img.ActualWidth <= 20 Then
        SftTree1.RowColumnHeader.Image = Img
        SftTree1.Header(1).Image = Img
    Else
        SftTree1.RowColumnHeader.Image.Clear
        SftTree1.Header(1).Image.Clear
    End If
    
End Sub
    
Private Sub ToggleImage(Img As SftPictureObject)
    Select Case Img.Appearance
    Case sftImageCheckboxNo
        Img.Appearance = sftImageCheckboxYes
    Case sftImageCheckboxYes
        Img.Appearance = sftImageCheckboxNo
    Case sftImageCheckboxUnknown
        Img.Appearance = sftImageCheckboxNo
    Case sftImageCheckboxNoDisabled
        Img.Appearance = sftImageCheckboxYesDisabled
    Case sftImageCheckboxYesDisabled
        Img.Appearance = sftImageCheckboxNoDisabled
    Case sftImageCheckboxUnknownDisabled
        Img.Appearance = sftImageCheckboxNoDisabled
    Case sftImageRadioButtonNo
        Img.Appearance = sftImageRadioButtonYes
    Case sftImageRadioButtonYes
        Img.Appearance = sftImageRadioButtonNo
    Case sftImageRadioButtonNoDisabled
        Img.Appearance = sftImageRadioButtonYesDisabled
    Case sftImageRadioButtonYesDisabled
        Img.Appearance = sftImageRadioButtonNoDisabled
    Case sftImageUp
        Img.Appearance = sftImageDown
    Case sftImageUpDisabled
        Img.Appearance = sftImageDownDisabled
    Case sftImageDown
        Img.Appearance = sftImageUp
    Case sftImageDownDisabled
        Img.Appearance = sftImageUpDisabled
    Case sftImageSortAsc
        Img.Appearance = sftImageSortDesc
    Case sftImageSortAscDisabled
        Img.Appearance = sftImageSortDescDisabled
    Case sftImageSortDesc
        Img.Appearance = sftImageSortAsc
    Case sftImageSortDescDisabled
        Img.Appearance = sftImageSortAscDisabled
    Case Else
        ' nothing
    End Select
End Sub

Private Sub PropagateImage(ByVal ItemIndex As Integer, Img As SftPictureObject)
    ' don't use images that are too large in the other areas
    If Img.ActualHeight <= 20 And Img.ActualWidth < 20 Then
        SftTree1.Item(ItemIndex).Image = Img
        SftTree1.Item(ItemIndex).LabelImage = Img
        SftTree1.Item(ItemIndex).RowHeader.Image = Img
    End If
End Sub

Private Sub UpdatePictures(ByVal ItemIndex As Integer, ByVal Pic As StdPicture, ByVal Align As SftTreeHAlignConstants)
    Dim C As SftTreeCell
    Set C = SftTree1.Cell(ItemIndex, 0)
    Set C.Image.Picture = Pic
    C.ImageHAlign = Align
    PropagateImage ItemIndex, C.Image
End Sub

Private Sub UpdateImages(ByVal ItemIndex As Integer, ByVal Pic As LONG_PTR, ByVal Align As SftTreeHAlignConstants)
    Dim C As SftTreeCell
    Set C = SftTree1.Cell(ItemIndex, 0)
    C.Image.SetImage Pic, True
    C.ImageHAlign = Align
    PropagateImage ItemIndex, C.Image
End Sub

Private Sub UpdateImageList(ByVal ItemIndex As Integer, ByVal ImageListControl As ImageList, ByVal I As Integer, ByVal Align As SftTreeHAlignConstants)
    Dim C As SftTreeCell
    Set C = SftTree1.Cell(ItemIndex, 0)
    C.Image.SetImageList ImageListControl, I
    C.ImageHAlign = Align
    PropagateImage ItemIndex, C.Image
End Sub

Private Sub UpdateColor(ByVal ItemIndex As Integer, ByVal Clr As OLE_COLOR, ByVal Align As SftTreeHAlignConstants)
    Dim C As SftTreeCell
    Set C = SftTree1.Cell(ItemIndex, 0)
    C.Image.SetColorSample Clr, vbBlack
    C.Image.Width = 12
    C.Image.Height = 12
    C.ImageHAlign = Align
    PropagateImage ItemIndex, C.Image
End Sub

Private Sub AddColor(ByVal Text As String, ByVal Clr As OLE_COLOR)
    Dim I As Integer
    I = SftTree1.Items.Add(Text)
    SftTree1.Item(I).Level = 2
    UpdateColor I, Clr, halignSftTreeRight
End Sub
    
Private Sub UpdateBuiltinImage(ByVal ItemIndex As Integer, ByVal Style As SftPictureImageConstants, ByVal wPix As Integer, ByVal hPix As Integer, ByVal Align As SftTreeHAlignConstants)
    Dim C As SftTreeCell
    Set C = SftTree1.Cell(ItemIndex, 0)
    C.Image.Appearance = Style
    C.Image.Width = wPix
    C.Image.Height = hPix
    C.ImageHAlign = Align
    PropagateImage ItemIndex, C.Image
End Sub

Private Sub AddBuiltinImage(ByVal Text As String, ByVal Style As SftPictureImageConstants, ByVal wPix As Integer, ByVal hPix As Integer)
    Dim I As Integer
    I = SftTree1.Items.Add(Text)
    SftTree1.Item(I).Level = 2
    UpdateBuiltinImage I, Style, wPix, hPix, halignSftTreeRight
End Sub

Private Sub ShowSortDirection(ByVal Ascending As Boolean)
    If Ascending Then
        SftTree1.Header(0).Image.Appearance = sftImageSortAsc
    Else
        SftTree1.Header(0).Image.Appearance = sftImageSortDesc
    End If
    SortDirection = Ascending
End Sub
    
Private Sub SetSortDirection(ByVal NewDirection As Boolean)
    ShowSortDirection NewDirection
    If NewDirection Then
        SftTree1.Items.SortDependents -1, 0, sortSftTreeAscending
    Else
        SftTree1.Items.SortDependents -1, 0, sortSftTreeDescending
    End If
End Sub


Private Sub Form_Load()
    Dim ItemIndex As Integer, I As Integer
    Dim C As Integer, Count As Integer
    
    SortDirection = False

    With SftTree1
        ItemIndex = .Items.Add("Progress Bars")
        .Cell(ItemIndex, 1).Text = "SftTree/OCX supports progress bars as cell background (partial or full size)."
        
        ' add progress bar samples
        
        I = .Items.Add("Progress Bar - Full Size")
        .Item(I).Level = 1
        .Cell(I, 0).ProgressMax = 100    ' maximum value 0-100
        .Cell(I, 0).ProgressValue = 33   ' current value

        I = .Items.Add("Progress Bar - Partial")
        .Item(I).Level = 1
        .Cell(I, 0).ProgressColorOrientation = horizontalDefaultOrientationSftTree
        .Cell(I, 0).ProgressStyle = smallDefaultProgressStyleSftTree
        .Cell(I, 0).ProgressMax = 200    ' maximum value 0-200
        .Cell(I, 0).ProgressValue = 33   ' current value

        I = .Items.Add("Progress Bar - with gradient fill")
        .Item(I).Level = 1
        .Cell(I, 0).ProgressColorOrientation = horizontalDefaultOrientationSftTree
        .Cell(I, 0).ProgressStyle = smallDefaultProgressStyleSftTree
        .Cell(I, 0).ProgressColor = &H8080&
        .Cell(I, 0).ProgressColorEnd = &HFFFF&
        .Cell(I, 0).ProgressMax = 50     ' maximum value 0-50
        .Cell(I, 0).ProgressValue = 40   ' current value

        I = .Items.Add("Progress Bar - customizable colors")
        .Item(I).Level = 1
        Dim cellObj As SftTreeCell
        Set cellObj = .Cell(I, 0)
        cellObj.ProgressColorOrientation = verticalDefaultOrientationSftTree
        cellObj.ProgressStyle = smallDefaultProgressStyleSftTree
        cellObj.ProgressColor = &H8080&
        cellObj.ProgressColorEnd = &HFFFF&
        cellObj.ProgressMax = 150    ' maximum value 0-150
        cellObj.ProgressValue = 40   ' current value
        cellObj.BackColor = &H80000005
        cellObj.BackColorEnd = &HFF&
        cellObj.BackColorOrientation = horizontalDefaultOrientationSftTree
      
        ' Picture Types
        
        ItemIndex = .Items.Add("Supported Picture Types")
        .Cell(ItemIndex, 1).Text = "SftTree/OCX supports numerous image types, such as GDI+ images, bitmaps, icons, ImageLists and also offers numerous built-in images."
    
        ' add GDI+ samples
        
        ItemIndex = .Items.Add("GDI+ Images")
        .Item(ItemIndex).Level = 1
        .Cell(ItemIndex, 1).Text = "All GDI+ images are supported, like GIF, JPEG, Exif, PNG, TIFF and device-independent bitmaps (up to 64bpp) with semi-transparent and translucent areas."

        I = .Items.Add("PNG Sample with alpha-channel for translucent edges")
        .Item(I).Level = 2
        Dim PicturePNG1 As LONG_PTR
        PicturePNG1 = SftTree1.LoadGDIPlusImage(App.Path + "\pic_warn_32.png", False)
        UpdateImages I, PicturePNG1, halignSftTreeRight

        I = .Items.Add("Another PNG Sample with alpha-channel for translucent edges")
        .Item(I).Level = 2
        Dim PicturePNG2 As LONG_PTR
        PicturePNG2 = SftTree1.LoadGDIPlusImage(App.Path + "\pic_world_48.png", False)
        UpdateImages I, PicturePNG2, halignSftTreeRight

        ' add bitmap samples

        ItemIndex = .Items.Add("Bitmaps")
        .Item(ItemIndex).Level = 1
        .Cell(ItemIndex, 1).Text = "Bitmaps can be of varying sizes and also support Bitmap Transparency, which allows the background to show through the image (in areas selected by the bitmap designer)."

        I = .Items.Add("Large Bitmap")
        .Item(I).Level = 2
        UpdatePictures I, PictureLogo, halignSftTreeRight

        I = .Items.Add("Various bitmap sizes")
        .Item(I).Level = 2
        UpdatePictures I, PictureSmallBitmap, halignSftTreeRight

        ' add icon samples
        
        ItemIndex = .Items.Add("Icons")
        .Item(ItemIndex).Level = 1
        .Cell(ItemIndex, 1).Text = "The supported icons can be standard size icons (32x32) or any other size supported by the operating system."

        I = .Items.Add("Standard Icon (32x32)")
        .Item(I).Level = 2
        UpdatePictures I, PictureIcon, halignSftTreeRight

        I = .Items.Add("Any other size")
        .Item(I).Level = 2
        UpdatePictures I, PictureIconSmall, halignSftTreeRight

        ' add imagelist samples
        
        ItemIndex = .Items.Add("ImageLists")
        .Item(ItemIndex).Level = 1
        .Cell(ItemIndex, 1).Text = "Complete ImageList support simplifies bitmap handling and can avoid the limited resource availability on earlier Windows versions."
                        
        Count = ImageList1.ListImages.Count
        For C = 1 To Count
            I = .Items.Add("Image " & C)
            .Item(I).Level = 2
            UpdateImageList I, ImageList1, C, halignSftTreeRight
        Next
    
        ' add color samples
        
        ItemIndex = .Items.Add("Color Samples")
        .Item(ItemIndex).Level = 1
        .Cell(ItemIndex, 1).Text = "Using the built-in color sample image, simple color selection can easily be implemented.  Color samples can display all colors available."
        
        AddColor "Black", vbBlack
        AddColor "Blue", vbBlue
        AddColor "Cyan", vbCyan
        AddColor "Green", vbGreen
        AddColor "Magenta", vbMagenta
        AddColor "Red", vbRed
        AddColor "White", vbWhite
        AddColor "Yellow", vbYellow
        
        AddColor "3DDKSHADOW - Dark shadow for 3D elements", vb3DDKShadow
        AddColor "3DFACE - Face color for 3D elements", vb3DFace
        AddColor "3DHILIGHT - Edges facing the light source", vb3DHighlight
        AddColor "3DLIGHT - Edges facing the light source", vb3DLight
        AddColor "3DSHADOW - Edges facing away from the light source", vb3DShadow
        AddColor "INFOBK - Background color for tooltip controls", vbInfoBackground
        AddColor "INFOTEXT - Text color for tooltip controls", vbInfoText
        AddColor "MENUTEXT - Text in menus", vbMenuText
        AddColor "ACTIVEBORDER - Active window border", vbActiveBorder
        AddColor "ACTIVECAPTION - Active window caption", vbActiveTitleBar
        AddColor "APPWORKSPACE - Background color MDI applications", vbApplicationWorkspace
        AddColor "BACKGROUND - Desktop", vbDesktop
        AddColor "BTNFACE - Face shading on push buttons", vbButtonFace
        AddColor "BTNHILIGHT - Highlight color for buttons", vb3DHighlight
        AddColor "BTNSHADOW - Edge shading on push buttons", vbButtonShadow
        AddColor "BTNTEXT - Text on push buttons", vbButtonText
        AddColor "CAPTIONTEXT - Text in caption", vbTitleBarText
        AddColor "GRAYTEXT - Grayed (disabled) text", vbGrayText
        AddColor "HIGHLIGHT - Selected Item(s)", vbHighlight
        AddColor "HIGHLIGHTTEXT - Text of selected item(s)", vbHighlightText
        AddColor "INACTIVEBORDER - Inactive window border", vbInactiveBorder
        AddColor "INACTIVECAPTION - Inactive window caption", vbInactiveTitleBar
        AddColor "INACTIVECAPTIONTEXT - Inactive caption text color", vbInactiveCaptionText
        AddColor "MENU - Menu background", vbMenuBar
        AddColor "SCROLLBAR - Scroll bar gray area", vbScrollBars
        AddColor "WINDOW - Window background", vbWindowBackground
        AddColor "WINDOWFRAME - Window frame", vbWindowFrame
        AddColor "WINDOWTEXT - Text in windows", vbWindowText
    
        ' add predefined image samples
        
        ItemIndex = .Items.Add("Predefined (Built-in) Pictures")
        .Cell(ItemIndex, 1).Text = "Predefined images are available for commonly used items, such as check boxes, radio buttons, sort direction indicators and more..."
        
        ItemIndex = .Items.Add("Check Boxes - Honors Windows Themes")
        .Item(ItemIndex).Level = 1
        
        AddBuiltinImage "Enabled, Selected Check Box", sftImageCheckboxYes, 14, 14
        AddBuiltinImage "Disabled, Selected Check Box", sftImageCheckboxYesDisabled, 14, 14
        AddBuiltinImage "Enabled Check Box", sftImageCheckboxNo, 14, 14
        AddBuiltinImage "Disabled Check Box", sftImageCheckboxNoDisabled, 14, 14
        AddBuiltinImage "Enabled, Unknown Check Box", sftImageCheckboxUnknown, 14, 14
        AddBuiltinImage "Disabled, Unknown Check Box", sftImageCheckboxUnknownDisabled, 14, 14
        
        ItemIndex = .Items.Add("Radio Buttons - Honors Windows Themes")
        .Item(ItemIndex).Level = 1
        
        AddBuiltinImage "Enabled, Selected Radio Button", sftImageRadioButtonYes, 14, 14
        AddBuiltinImage "Disabled, Selected Radio Button", sftImageRadioButtonYesDisabled, 14, 14
        AddBuiltinImage "Enabled Radio Button", sftImageRadioButtonNo, 14, 14
        AddBuiltinImage "Disabled Radio Button", sftImageRadioButtonNoDisabled, 14, 14

        ItemIndex = .Items.Add("Up/Down Buttons - Honors Windows Themes")
        .Item(ItemIndex).Level = 1
        
        AddBuiltinImage "Enabled Up Button", sftImageUp, 14, 14
        AddBuiltinImage "Disabled Up Button", sftImageUpDisabled, 14, 14
        AddBuiltinImage "Enabled Down Button", sftImageDown, 14, 14
        AddBuiltinImage "Disabled Down Button", sftImageDownDisabled, 14, 14

        ItemIndex = .Items.Add("Sort Direction Indicator")
        .Item(ItemIndex).Level = 1
        
        AddBuiltinImage "Enabled Ascending Indicator", sftImageSortAsc, 8, 8
        AddBuiltinImage "Disabled Ascending Indicator", sftImageSortAscDisabled, 8, 8
        AddBuiltinImage "Enabled Descending Indicator", sftImageSortDesc, 8, 8
        AddBuiltinImage "Disabled Descending Indicator", sftImageSortDescDisabled, 8, 8
        
        
        .RowHeaders.MakeOptimal ' make the row headers optimal
        .Column(0).MakeOptimal  ' make the first column optimal
        .Items.RecalcHorizontalExtent ' update horizontal scroll bar

        .Item(0).Selected = True
        .Items.Current = 0
        
        CopyImageFromCurrentItem
    
    End With
End Sub

Private Sub SftTree1_ItemClick(ByVal ItemIndex As Long, ByVal ColIndex As Integer, ByVal AreaType As Integer, ByVal Button As Integer, ByVal Shift As Integer)
    Dim Area As SftTreeAreaTypeConstants
    Area = AreaType
    If Area = constSftTreeExpandAll Then
        SftTree1.Item(ItemIndex).Expand True, True
    ElseIf Area = constSftTreeColumn And ColIndex = 0 Then
        SetSortDirection Not SortDirection
    ElseIf Area = constSftTreeCellGraphic Then
        ToggleImage SftTree1.Cell(ItemIndex, ColIndex).Image
    ElseIf Area = constSftTreeItem Then
        ToggleImage SftTree1.Item(ItemIndex).Image
    ElseIf Area = constSftTreeLabel Then
        ToggleImage SftTree1.Item(ItemIndex).LabelImage
    End If
End Sub

Private Sub SftTree1_ItemDblClick(ByVal ItemIndex As Long, ByVal ColIndex As Integer, ByVal AreaType As Integer, ByVal Button As Integer, ByVal Shift As Integer)
    Dim Area As SftTreeAreaTypeConstants
    Area = AreaType
    If Area = constSftTreeColumnRes Then
        SftTree1.Column(ColIndex).MakeOptimal ' Make column width optimal
        SftTree1.Items.RecalcHorizontalExtent ' Update horizontal scroll bar
    ElseIf Area = constSftTreeColumn And ColIndex = 0 Then
        SetSortDirection Not SortDirection
    ElseIf Area = constSftTreeCellGraphic Then
        ToggleImage SftTree1.Cell(ItemIndex, ColIndex).Image
    End If
End Sub

Private Sub SftTree1_SelectionChange()
    CopyImageFromCurrentItem
End Sub

Private Sub Timer1_Timer()
    ' update all cells that have a progress bar by incrementing the progress value
    Dim Total As Integer, Cols As Integer, ItemIndex As Integer
    Total = SftTree1.Items.Count
    For ItemIndex = 0 To Total - 1
        Dim cellObj As SftTreeCell
        Set cellObj = SftTree1.Cell(ItemIndex, 0)
        If cellObj.ProgressMax > 0 Then
            cellObj.ProgressValue = (cellObj.ProgressValue + 4) Mod cellObj.ProgressMax
        End If
    Next
End Sub

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