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
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
SftTree/NET 2.0 - Tree Control
This sample illustrates sorting, column reordering, responding to column header clicks, context menus, controlling expand/collapse buttons and plus/minus graphics.
The source code is located at C:\Program Files (x86)\Softelvdm\SftTree OCX 8.0\Samples\VB6\BookTable\Form1.frm or C:\Program Files\Softelvdm\SftTree OCX 8.0\Samples\VB6\BookTable\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. - BookTable Sample"
ClientHeight = 6045
ClientLeft = 2550
ClientTop = 1935
ClientWidth = 6720
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 = 6045
ScaleMode = 0 'User
ScaleWidth = 6720
Begin SftTreeLib80.SftTree SftTree1
Height = 4332
Left = 120
TabIndex = 6
Top = 600
Width = 5292
PropVer = 75
xcx = 9340
xcy = 7646
PropFile = ""
PropDesignTime = 1
DeletePropFile = 0
IntVal = 55
xBfStyle1 = 64051416
xBfStyle2 = -1374550801
xBfStyle3 = -1421825001
xBfStyle4 = 1153389545
FlatProperties = 0
Appearance = 1
AutoRespond = 1
BackgroundStyle = 0
BackgroundX = 0
BackgroundY = 0
BorderStyle = 0
ButtonStyle = 2
CellEventHandling= 0
CellEditStyle = 0
CellEditLimit = 0
ColumnCount = 3
CopyItemDataString= 0
CustomCode = 0
DragImage = -842150451
DragMethod = 1
DragType = 3
Enabled = 1
HandleReturn = -842150451
MouseIcon = "Form1.frx":0000
MousePointer = 0
LeftButtonOnly = 0
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 = 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= 0
CharSearchMode = 1
DropHighlightColor= -2147483635
DropHighlightStyle= 1
EditNoFocusStyle= 2
FlybyHighlight = 1
ForeColor = -2147483640
ForeColorOdd = -2147483640
GrayedColor = -2147483631
GridHorizontalColor= -2147483632
GridStyle = 6
GridVerticalColor= -2147483632
HilightColor = -2147483628
HorizontalExtentPix= 0
HorizontalExtent2Pix= 0
HorizontalOffsetPix= 0
HorizontalOffset2Pix= 0
Indentation = -1
ItemImageAlign = 1
Lines = 3
MaxHeightPix = 0
MinHeightPix = 0
MultiSelect = 0
NoFocusStyle = 0
NoSelection = 1
RubberbandSelection= 1
SelectBackColor = -2147483635
SelectBackColorNoFocus= -2147483633
SelectForeColor = -2147483634
SelectForeColorNoFocus= -2147483630
ShadowColor = -2147483632
Style = 1
ScrollTips = 1
SelectionArea = 1
SelectStyle = 2
ShowFocusRectangle= 1
ToolTipAlways = 0
ToolTipBackColor= -1
ToolTipForeColor= -1
ToolTipsUseEntireCell= 1
TopIndex = 0
TreeLineColor = -2147483632
TreeLineGrayedColor= -2147483631
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 = 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 = 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 = 1
CellVAlign = 0
CellWordWrap = 0
ForeColor = -1
Merge = 1
MergeInto = 1
MinWidth = 0
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 = 1
Locked = 0
ImageHAlign = 2
ImageVAlign = 0
RemainUp = 1
Text = "Contents"
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 = 0
ForeColor = -1
Merge = 1
MergeInto = 1
MinWidth = 0
SelectBackColor = -1
SelectForeColor = -1
ToolTip = 1
Object.Width = 100
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
BeginProperty Column(2) {9EBAA938-293D-44FA-9989-08F078763A1F}
BackColor = -1
CellHAlign = 2
CellMultiline = 1
CellVAlign = 0
CellWordWrap = 0
ForeColor = -1
Merge = 1
MergeInto = 1
MinWidth = 0
SelectBackColor = -1
SelectForeColor = -1
ToolTip = 1
Object.Width = 100
RealPos = 2
DispPos = 2
BackColorEnd = -1
SelectBackColorEnd= -1
ProgressColor = -1
ProgressColorEnd= -1
BackColorOrientation= 0
ProgressColor = -1
ProgressColorEnd= -1
ProgressColorOrientation= 0
ProgressStyle = 0
EndProperty
BeginProperty Header(2) {9EBAA93A-293D-44FA-9989-08F078763A1F}
Enabled = 1
KeepPosition = 0
Locked = 0
ImageHAlign = 2
ImageVAlign = 0
RemainUp = 1
Text = "Size"
TextHAlign = 2
TextVAlign = 0
BackColor = -1
ForeColor = -1
SelectBackColor = -1
SelectForeColor = -1
BackColorDisabled= -1
ForeColorDisabled= -1
OverrideTheme = 0
Button = 0
EndProperty
BeginProperty Footer(2) {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= 3
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.CheckBox ShowPlusMin
Caption = "Show plus/minus graphic"
Height = 252
Left = 120
TabIndex = 1
Top = 5040
Width = 2292
End
Begin VB.CheckBox Ugly
Caption = "Use ""plain"" buttons"
Height = 252
Left = 3360
TabIndex = 2
Top = 5040
Width = 2292
End
Begin VB.CommandButton Command1
Cancel = -1 'True
Caption = "Close"
Default = -1 'True
Height = 372
Left = 5520
TabIndex = 3
Top = 600
Width = 1092
End
Begin VB.Label Label5
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 = 5520
TabIndex = 7
Top = 2040
Visible = 0 'False
Width = 1095
End
Begin VB.Image Minus
Height = 210
Left = 3840
Picture = "Form1.frx":001C
Top = 5640
Width = 210
End
Begin VB.Image Plus
Height = 210
Left = 3360
Picture = "Form1.frx":010E
Top = 5640
Width = 210
End
Begin VB.Label Label4
Caption = "Bitmaps used as plus/minus graphics"
Height = 255
Left = 3360
TabIndex = 0
Top = 5400
Width = 3255
End
Begin VB.Image UglyButtons
Height = 135
Left = 5880
Picture = "Form1.frx":0200
Top = 5160
Width = 600
End
Begin VB.Label Label3
Caption = $"Form1.frx":0336
Height = 492
Left = 120
TabIndex = 5
Top = 120
UseMnemonic = 0 'False
Width = 6492
WordWrap = -1 'True
End
Begin VB.Image Topic
Height = 240
Left = 840
Picture = "Form1.frx":03E5
Top = 5640
Width = 240
End
Begin VB.Image BookClosed
Height = 240
Left = 480
Picture = "Form1.frx":04E7
Top = 5640
Width = 240
End
Begin VB.Image BookOpen
Height = 240
Left = 120
Picture = "Form1.frx":05E9
Top = 5640
Width = 240
End
Begin VB.Label Label1
Caption = "Bitmaps used for the tree control:"
Height = 255
Left = 120
TabIndex = 4
Top = 5400
Width = 3135
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()
End
End Sub
Private Sub Form_Load()
Dim Bk As Integer, Ch As Integer, Sect As Integer, ItemIndex As Integer
Dim BookIndex As Integer
Dim size As Integer
Dim CellFont As New StdFont
Randomize
With SftTree1
' Mass-Update
.BulkUpdate = True
' set default item graphic. This can also be done at design time
Set .Items.ItemImageExpandable.Picture = BookClosed.Picture
Set .Items.ItemImageExpanded.Picture = BookOpen.Picture
Set .Items.ItemImageLeaf.Picture = Topic.Picture
' set the column header sort indicators
SftTree1.Headers.SortIndicators = headerSortIndicatorsSftTreeAuto
SftTree1.Header(0).SortIndicator = sortIndicatorSftTreeAscending
' set the cell font for books
Set CellFont = Font
CellFont.Bold = True
' Add all available options
For Bk = 1 To 4
' add a book
BookIndex = .Items.Add("Book " & Bk)
.Cell(BookIndex, 1).Text = "Description for book " & Bk
size = Int((1000 * Rnd) + 1)
.Cell(BookIndex, 2).Text = size
.Item(BookIndex).Data = size
' add chapters
For Ch = 1 To 2
ItemIndex = .Items.Add("Chapter " & Ch)
.Item(ItemIndex).Level = 1
' add sections
For Sect = 1 To 2
ItemIndex = .Items.Add("Section " & Sect)
.Item(ItemIndex).Level = 2
Next Sect
Next Ch
' after adding the book and all dependent items, we
' collapse the item, so it's up to the user to expand it
.Item(BookIndex).Collapse False
' set font
Set .Cell(BookIndex, 0).Font = CellFont
Next Bk
' End of Mass-Update
.BulkUpdate = False
' Make columns optimal
.ColumnsObj.MakeOptimal
' allow horizontal scrolling
.Items.RecalcHorizontalExtent
End With
End Sub
Private Sub ShowPlusMin_Click()
If ShowPlusMin.Value = 0 Then
SftTree1.Items.PlusMinusImageExpandable.Clear
SftTree1.Items.PlusMinusImageExpanded.Clear
Else
Set SftTree1.Items.PlusMinusImageExpandable.Picture = Plus.Picture
Set SftTree1.Items.PlusMinusImageExpanded.Picture = Minus.Picture
End If
End Sub
Private Sub Ugly_Click()
If Ugly.Value = 0 Then
SftTree1.ButtonPicture = Nothing
Else
Set SftTree1.ButtonPicture = UglyButtons.Picture
End If
End Sub
Private Sub SortHeader()
With SftTree1
Dim SortedColumn As Integer
' get the new, sorted column
SortedColumn = .Headers.SortedColumn
' Sort the data based on the sort indicator
' Note that column 2 is sorted by Item.Data, which is an integer value (book size in pages)
If .Header(SortedColumn).SortIndicator = sortIndicatorSftTreeAscending Then
If SortedColumn = 2 Then
.Items.SortDependents -1, SortedColumn, sortSftTreeAscItemData
Else
.Items.SortDependents -1, SortedColumn, sortSftTreeAscending
End If
Else
If SortedColumn = 2 Then
.Items.SortDependents -1, SortedColumn, sortSftTreeDscItemData
Else
.Items.SortDependents -1, SortedColumn, sortSftTreeDescending
End If
End If
End With
End Sub
Private Sub HeaderMenu()
Dim Count As Integer
Count = 0
If SftTree1.Column(0).WidthPix > 0 Then
MenuForm.ShowContents.Checked = True
Count = Count + 1
Else
MenuForm.ShowContents.Checked = False
End If
If SftTree1.Column(1).WidthPix > 0 Then
MenuForm.ShowDescription.Checked = True
Count = Count + 1
Else
MenuForm.ShowDescription.Checked = False
End If
If SftTree1.Column(2).WidthPix > 0 Then
MenuForm.ShowSize.Checked = True
Count = Count + 1
Else
MenuForm.ShowSize.Checked = False
End If
If Count <= 1 Then
If MenuForm.ShowContents.Checked Then MenuForm.ShowContents.Enabled = False
If MenuForm.ShowDescription.Checked Then MenuForm.ShowDescription.Enabled = False
If MenuForm.ShowSize.Checked Then MenuForm.ShowSize.Enabled = False
Else
MenuForm.ShowContents.Enabled = True
MenuForm.ShowDescription.Enabled = True
MenuForm.ShowSize.Enabled = True
End If
MenuForm.ShowAll.Enabled = Count < 3
SftTree1.CancelMode
PopupMenu MenuForm.HeaderPopup
End Sub
Private Sub SftTree1_ContextMenu(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
' Determine click context menu for header or item
Dim l As Single, t As Single, h As Single, w As Single
SftTree1.Headers.GetPosition l, t, w, h
If X >= l And X < l + w And Y >= t And Y <= t + h Then
HeaderMenu
Exit Sub
End If
' determine item right-clicked
Dim ItemIndex As Long
ItemIndex = SftTree1.Items.HitTest(X, Y)
If ItemIndex >= 0 And ItemIndex < SftTree1.Items.Count Then
SftTree1.Items.Current = ItemIndex
SftTree1.Item(ItemIndex).Selected = True
SftTree1.CancelMode
PopupMenu MenuForm.ItemPopup
End If
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)
With SftTree1
If AreaType = constSftTreeColumn And Button = constSftTreeLeftButton Then
SortHeader
ElseIf AreaType = constSftTreeExpandAll Then
.Item(ItemIndex).Expand False, True
End If
End With
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)
With SftTree1
If AreaType = constSftTreeColumnRes And Button = constSftTreeLeftButton Then
.Column(ColIndex).MakeOptimal
.Items.RecalcHorizontalExtent
ElseIf AreaType = constSftTreeColumn And Button = constSftTreeLeftButton Then
SortHeader
End If
End With
End Sub
