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
This sample illustrates images, checkboxes, radiobuttons, more.
The source code is located at C:\Program Files (x86)\Softelvdm\SftBox OCX 5.0\Samples\Visual Studio - VB.NET\Pictures\Form1.vb or C:\Program Files\Softelvdm\SftBox OCX 5.0\Samples\Visual Studio - VB.NET\Pictures\Form1.vb (on 32-bit Windows versions).
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Application.Exit()
End Sub
Private Sub CopyImageFromCurrentItem()
Dim ItemIndex As Integer
Dim Img As SftPictureObject
ItemIndex = AxSftBox1.Items.Selection
If ItemIndex < 0 Then Exit Sub
' don't use images that are too large in the other areas
Img = AxSftBox1.get_Cell(ItemIndex, 0).Image
If Img.ActualHeight <= 20 And Img.ActualWidth <= 20 Then
AxSftBox1.RowColumnHeader.Image = Img
AxSftBox1.get_Header(1).Image = Img
Else
AxSftBox1.RowColumnHeader.Image.Clear()
AxSftBox1.get_Header(1).Image.Clear()
End If
End Sub
Private Sub ToggleImage(ByVal Img As SftPictureObject)
Select Case Img.Appearance
Case SftPictureImageConstants.sftImageCheckboxNo
Img.Appearance = SftPictureImageConstants.sftImageCheckboxYes
Case SftPictureImageConstants.sftImageCheckboxYes
Img.Appearance = SftPictureImageConstants.sftImageCheckboxNo
Case SftPictureImageConstants.sftImageCheckboxUnknown
Img.Appearance = SftPictureImageConstants.sftImageCheckboxNo
Case SftPictureImageConstants.sftImageCheckboxNoDisabled
Img.Appearance = SftPictureImageConstants.sftImageCheckboxYesDisabled
Case SftPictureImageConstants.sftImageCheckboxYesDisabled
Img.Appearance = SftPictureImageConstants.sftImageCheckboxNoDisabled
Case SftPictureImageConstants.sftImageCheckboxUnknownDisabled
Img.Appearance = SftPictureImageConstants.sftImageCheckboxNoDisabled
Case SftPictureImageConstants.sftImageRadioButtonNo
Img.Appearance = SftPictureImageConstants.sftImageRadioButtonYes
Case SftPictureImageConstants.sftImageRadioButtonYes
Img.Appearance = SftPictureImageConstants.sftImageRadioButtonNo
Case SftPictureImageConstants.sftImageRadioButtonNoDisabled
Img.Appearance = SftPictureImageConstants.sftImageRadioButtonYesDisabled
Case SftPictureImageConstants.sftImageRadioButtonYesDisabled
Img.Appearance = SftPictureImageConstants.sftImageRadioButtonNoDisabled
Case SftPictureImageConstants.sftImageUp
Img.Appearance = SftPictureImageConstants.sftImageDown
Case SftPictureImageConstants.sftImageUpDisabled
Img.Appearance = SftPictureImageConstants.sftImageDownDisabled
Case SftPictureImageConstants.sftImageDown
Img.Appearance = SftPictureImageConstants.sftImageUp
Case SftPictureImageConstants.sftImageDownDisabled
Img.Appearance = SftPictureImageConstants.sftImageUpDisabled
Case SftPictureImageConstants.sftImageSortAsc
Img.Appearance = SftPictureImageConstants.sftImageSortDesc
Case SftPictureImageConstants.sftImageSortAscDisabled
Img.Appearance = SftPictureImageConstants.sftImageSortDescDisabled
Case SftPictureImageConstants.sftImageSortDesc
Img.Appearance = SftPictureImageConstants.sftImageSortAsc
Case SftPictureImageConstants.sftImageSortDescDisabled
Img.Appearance = SftPictureImageConstants.sftImageSortAscDisabled
End Select
End Sub
Private Sub PropagateImage(ByVal ItemIndex As Integer, ByVal Img As SftPictureObject)
' don't use images that are too large in the other areas
If Img.ActualHeight <= 20 And Img.ActualWidth < 20 Then
AxSftBox1.get_Item(ItemIndex).Image = Img
AxSftBox1.get_Item(ItemIndex).LabelImage = Img
AxSftBox1.get_Item(ItemIndex).RowHeader.Image = Img
End If
End Sub
Private Sub UpdateImages(ByVal ItemIndex As Integer, ByVal Img As Image, ByVal Align As SftBoxHAlignConstants)
Dim C As SftBoxCell
C = AxSftBox1.get_Cell(ItemIndex, 0)
C.Image.NETImageObject = Img
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 SftBoxHAlignConstants)
Dim C As SftBoxCell
C = AxSftBox1.get_Cell(ItemIndex, 0)
C.Image.SetImageListH(ImageListControl.Handle.ToInt32(), i)
C.ImageHAlign = Align
PropagateImage(ItemIndex, C.Image)
End Sub
Private Sub UpdateColor(ByVal ItemIndex As Integer, ByVal Clr As System.Drawing.Color, ByVal Align As SftBoxHAlignConstants)
Dim C As SftBoxCell
C = AxSftBox1.get_Cell(ItemIndex, 0)
C.Image.SetColorSample(OLECvt.ToOleColor(Clr), OLECvt.ToOleColor(Color.Black))
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 Color)
Dim i As Integer
i = AxSftBox1.Items.Add(Text)
AxSftBox1.get_Item(i).Level = 2
UpdateColor(i, Clr, SftBoxHAlignConstants.halignSftBoxRight)
End Sub
Private Sub UpdateBuiltinImage(ByVal ItemIndex As Integer, ByVal Style As SftPictureImageConstants, ByVal wPix As Integer, ByVal hPix As Integer, ByVal Align As SftBoxHAlignConstants)
Dim C As SftBoxCell
C = AxSftBox1.get_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 = AxSftBox1.Items.Add(Text)
AxSftBox1.get_Item(i).Level = 2
UpdateBuiltinImage(i, Style, wPix, hPix, SftBoxHAlignConstants.halignSftBoxRight)
End Sub
Private Sub ShowSortDirection(ByVal Ascending As Boolean)
If (Ascending) Then
AxSftBox1.get_Header(0).Image.Appearance = SftPictureImageConstants.sftImageSortAsc
Else
AxSftBox1.get_Header(0).Image.Appearance = SftPictureImageConstants.sftImageSortDesc
End If
m_SortDirection = Ascending
End Sub
Private Sub SetSortDirection(ByVal NewDirection As Boolean)
ShowSortDirection(NewDirection)
If NewDirection Then
AxSftBox1.Items.Sort(-1, 0, SftBoxSortConstants.sortSftBoxAscending)
Else
AxSftBox1.Items.Sort(-1, 0, SftBoxSortConstants.sortSftBoxDescending)
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ItemIndex As Integer
ItemIndex = AxSftBox1.Items.Add("Supported Picture Types")
AxSftBox1.get_Cell(ItemIndex, 1).Text = "SftBox/OCX supports numerous image types, GDI+ images, such as bitmaps, icons, ImageLists and also offers numerous built-in images."
' add GDI+ samples
ItemIndex = AxSftBox1.Items.Add("GDI+ Images")
AxSftBox1.get_Item(ItemIndex).Level = 1
AxSftBox1.get_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."
Dim I As Integer
I = AxSftBox1.Items.Add("PNG Sample with alpha-channel for translucent edges")
AxSftBox1.get_Item(I).Level = 2
UpdateImages(I, PicturePNG1.Image, SftBoxHAlignConstants.halignSftBoxRight)
I = AxSftBox1.Items.Add("Another PNG Sample with alpha-channel for translucent edges")
AxSftBox1.get_Item(I).Level = 2
UpdateImages(I, PicturePNG2.Image, SftBoxHAlignConstants.halignSftBoxRight)
' add bitmap samples
ItemIndex = AxSftBox1.Items.Add("Bitmaps")
AxSftBox1.get_Item(ItemIndex).Level = 1
AxSftBox1.get_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 = AxSftBox1.Items.Add("Large Bitmap")
AxSftBox1.get_Item(I).Level = 2
UpdateImages(I, PictureLogo.Image, SftBoxHAlignConstants.halignSftBoxRight)
I = AxSftBox1.Items.Add("Various bitmap sizes")
AxSftBox1.get_Item(I).Level = 2
UpdateImages(I, PictureSmallBitmap.Image, SftBoxHAlignConstants.halignSftBoxRight)
' add icon samples
ItemIndex = AxSftBox1.Items.Add("Icons")
AxSftBox1.get_Item(ItemIndex).Level = 1
AxSftBox1.get_Cell(ItemIndex, 1).Text = "The supported icons can be stardard size icons (32x32) or any other size supported by the operating system."
I = AxSftBox1.Items.Add("Standard Icon (32x32)")
AxSftBox1.get_Item(I).Level = 2
UpdateImages(I, PictureIcon.Image, SftBoxHAlignConstants.halignSftBoxRight)
I = AxSftBox1.Items.Add("Any other size")
AxSftBox1.get_Item(I).Level = 2
UpdateImages(I, PictureIconSmall.Image, SftBoxHAlignConstants.halignSftBoxRight)
' add imagelist samples
ItemIndex = AxSftBox1.Items.Add("ImageLists")
AxSftBox1.get_Item(ItemIndex).Level = 1
AxSftBox1.get_Cell(ItemIndex, 1).Text = "Complete ImageList support simplifies bitmap handling and can avoid the limited resource availability on earlier Windows versions."
Dim C As Integer
For C = 0 To imageList1.Images.Count - 1
I = AxSftBox1.Items.Add("Image " & C)
AxSftBox1.get_Item(I).Level = 2
UpdateImageList(I, imageList1, C, SftBoxHAlignConstants.halignSftBoxRight)
Next
' add color samples
ItemIndex = AxSftBox1.Items.Add("Color Samples")
AxSftBox1.get_Item(ItemIndex).Level = 1
AxSftBox1.get_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", System.Drawing.Color.Black)
AddColor("Blue", System.Drawing.Color.Blue)
AddColor("Cyan", System.Drawing.Color.Cyan)
AddColor("Green", System.Drawing.Color.Lime)
AddColor("Magenta", System.Drawing.Color.Magenta)
AddColor("Red", System.Drawing.Color.Red)
AddColor("White", System.Drawing.Color.White)
AddColor("Yellow", System.Drawing.Color.Yellow)
AddColor("3DDKSHADOW - Dark shadow for 3D elements", System.Drawing.SystemColors.ControlDarkDark)
AddColor("3DFACE - Face color for 3D elements", System.Drawing.SystemColors.Control)
AddColor("3DHILIGHT - Edges facing the light source", System.Drawing.SystemColors.ControlLightLight)
AddColor("3DLIGHT - Edges facing the light source", System.Drawing.SystemColors.ControlLight)
AddColor("3DSHADOW - Edges facing away from the light source", System.Drawing.SystemColors.ControlDark)
AddColor("INFOBK - Background color for tooltip controls", System.Drawing.SystemColors.Info)
AddColor("INFOTEXT - Text color for tooltip controls", System.Drawing.SystemColors.InfoText)
AddColor("MENUTEXT - Text in menus", System.Drawing.SystemColors.MenuText)
AddColor("ACTIVEBORDER - Active window border", System.Drawing.SystemColors.ActiveBorder)
AddColor("ACTIVECAPTION - Active window caption", System.Drawing.SystemColors.ActiveCaption)
AddColor("APPWORKSPACE - Background color MDI applications", System.Drawing.SystemColors.AppWorkspace)
AddColor("BACKGROUND - Desktop", System.Drawing.SystemColors.Desktop)
AddColor("BTNFACE - Face shading on push buttons", System.Drawing.SystemColors.Control)
AddColor("BTNHILIGHT - Highlight color for buttons", System.Drawing.SystemColors.ControlLightLight)
AddColor("BTNSHADOW - Edge shading on push buttons", System.Drawing.SystemColors.ControlDark)
AddColor("BTNTEXT - Text on push buttons", System.Drawing.SystemColors.ControlText)
AddColor("CAPTIONTEXT - Text in caption", System.Drawing.SystemColors.ActiveCaptionText)
AddColor("GRAYTEXT - Grayed (disabled) text", System.Drawing.SystemColors.GrayText)
AddColor("HIGHLIGHT - Selected Item(s)", System.Drawing.SystemColors.Highlight)
AddColor("HIGHLIGHTTEXT - Text of selected item(s)", System.Drawing.SystemColors.HighlightText)
AddColor("INACTIVEBORDER - Inactive window border", System.Drawing.SystemColors.InactiveBorder)
AddColor("INACTIVECAPTION - Inactive window caption", System.Drawing.SystemColors.InactiveCaption)
AddColor("INACTIVECAPTIONTEXT - Inactive caption text color", System.Drawing.SystemColors.InactiveCaptionText)
AddColor("MENU - Menu background", System.Drawing.SystemColors.Menu)
AddColor("SCROLLBAR - Scroll bar gray area", System.Drawing.SystemColors.ScrollBar)
AddColor("WINDOW - Window background", System.Drawing.SystemColors.Window)
AddColor("WINDOWFRAME - Window frame", System.Drawing.SystemColors.WindowFrame)
AddColor("WINDOWTEXT - Text in windows", System.Drawing.SystemColors.WindowText)
' add predefined image samples
ItemIndex = AxSftBox1.Items.Add("Predefined (Built-in) Pictures")
AxSftBox1.get_Cell(ItemIndex, 1).Text = "Predefined images are available for commonly used items, such as check boxes, radio buttons, sort direction indicators and more..."
ItemIndex = AxSftBox1.Items.Add("Check Boxes - Honors Windows Themes")
AxSftBox1.get_Item(ItemIndex).Level = 1
AddBuiltinImage("Enabled, Selected Check Box", SftPictureImageConstants.sftImageCheckboxYes, 14, 14)
AddBuiltinImage("Disabled, Selected Check Box", SftPictureImageConstants.sftImageCheckboxYesDisabled, 14, 14)
AddBuiltinImage("Enabled Check Box", SftPictureImageConstants.sftImageCheckboxNo, 14, 14)
AddBuiltinImage("Disabled Check Box", SftPictureImageConstants.sftImageCheckboxNoDisabled, 14, 14)
AddBuiltinImage("Enabled, Unknown Check Box", SftPictureImageConstants.sftImageCheckboxUnknown, 14, 14)
AddBuiltinImage("Disabled, Unknown Check Box", SftPictureImageConstants.sftImageCheckboxUnknownDisabled, 14, 14)
ItemIndex = AxSftBox1.Items.Add("Radio Buttons - Honors Windows Themes")
AxSftBox1.get_Item(ItemIndex).Level = 1
AddBuiltinImage("Enabled, Selected Radio Button", SftPictureImageConstants.sftImageRadioButtonYes, 14, 14)
AddBuiltinImage("Disabled, Selected Radio Button", SftPictureImageConstants.sftImageRadioButtonYesDisabled, 14, 14)
AddBuiltinImage("Enabled Radio Button", SftPictureImageConstants.sftImageRadioButtonNo, 14, 14)
AddBuiltinImage("Disabled Radio Button", SftPictureImageConstants.sftImageRadioButtonNoDisabled, 14, 14)
ItemIndex = AxSftBox1.Items.Add("Up/Down Buttons - Honors Windows Themes")
AxSftBox1.get_Item(ItemIndex).Level = 1
AddBuiltinImage("Enabled Up Button", SftPictureImageConstants.sftImageUp, 14, 14)
AddBuiltinImage("Disabled Up Button", SftPictureImageConstants.sftImageUpDisabled, 14, 14)
AddBuiltinImage("Enabled Down Button", SftPictureImageConstants.sftImageDown, 14, 14)
AddBuiltinImage("Disabled Down Button", SftPictureImageConstants.sftImageDownDisabled, 14, 14)
ItemIndex = AxSftBox1.Items.Add("Sort Direction Indicator")
AxSftBox1.get_Item(ItemIndex).Level = 1
AddBuiltinImage("Enabled Ascending Indicator", SftPictureImageConstants.sftImageSortAsc, 8, 8)
AddBuiltinImage("Disabled Ascending Indicator", SftPictureImageConstants.sftImageSortAscDisabled, 8, 8)
AddBuiltinImage("Enabled Descending Indicator", SftPictureImageConstants.sftImageSortDesc, 8, 8)
AddBuiltinImage("Disabled Descending Indicator", SftPictureImageConstants.sftImageSortDescDisabled, 8, 8)
AxSftBox1.RowHeaders.MakeOptimal(0) ' make the row headers optimal
AxSftBox1.get_Column(0).MakeOptimal(0) ' make the first column optimal
AxSftBox1.Items.RecalcHorizontalExtent(0) ' update horizontal scroll bar
AxSftBox1.Items.Selection = 0
CopyImageFromCurrentItem()
End Sub
Private Sub ExpandCollapseItem(ByVal ItemIndex As Long, ByVal Shift As Short)
Dim Item As SftBoxItem
Item = AxSftBox1.get_Item(ItemIndex)
If Item.Expanded Then
Item.Collapse(True)
Else
Item.Expand(True, (Shift And SftBoxKeyConstants.constSftBoxCtrlMask))
End If
End Sub
Private Sub AxSftBox1_ItemClick(ByVal sender As Object, ByVal e As AxSftBoxLib50._ISftBoxEvents_ItemClickEvent) Handles AxSftBox1.ItemClick
Select Case e.areaType
Case SftBoxAreaConstants.areaSftBoxColumn
If e.colNum = 0 Then
SetSortDirection(Not m_SortDirection)
End If
Case SftBoxAreaConstants.areaSftBoxCellGraphic
If e.part = SftBoxPortionConstants.partSftBoxDropDown Then
AxSftBox1.DropDown.Suppress() ' Make sure we don't close the drop down
End If
ToggleImage(AxSftBox1.get_Cell(e.itemIndex, e.colNum).Image)
Case SftBoxAreaConstants.areaSftBoxItem
If e.part = SftBoxPortionConstants.partSftBoxDropDown Then
AxSftBox1.DropDown.Suppress() ' Make sure we don't close the drop down
End If
ToggleImage(AxSftBox1.get_Item(e.itemIndex).Image)
Case SftBoxAreaConstants.areaSftBoxLabel
If e.part = SftBoxPortionConstants.partSftBoxDropDown Then
AxSftBox1.DropDown.Suppress() ' Make sure we don't close the drop down
End If
ToggleImage(AxSftBox1.get_Item(e.itemIndex).LabelImage)
Case SftBoxAreaConstants.areaSftBoxButton
If e.part = SftBoxPortionConstants.partSftBoxDropDown Then
AxSftBox1.DropDown.Suppress() ' Make sure we don't close the drop down
End If
ExpandCollapseItem(e.itemIndex, e.shift)
End Select
End Sub
Private Sub AxSftBox1_ItemDblClk(ByVal sender As Object, ByVal e As AxSftBoxLib50._ISftBoxEvents_ItemDblClkEvent) Handles AxSftBox1.ItemDblClk
Select Case e.areaType
Case SftBoxAreaConstants.areaSftBoxColumnRes
AxSftBox1.get_Column(e.colNum).MakeOptimal(0) ' Make column width optimal
AxSftBox1.Items.RecalcHorizontalExtent(0) ' Update horizontal scroll bar
Case SftBoxAreaConstants.areaSftBoxColumn
If e.colNum = 0 Then
SetSortDirection(Not m_SortDirection)
End If
Case SftBoxAreaConstants.areaSftBoxCellGraphic
If e.part = SftBoxPortionConstants.partSftBoxDropDown Then
AxSftBox1.DropDown.Suppress() ' Make sure we don't close the drop down
End If
ToggleImage(AxSftBox1.get_Cell(e.itemIndex, e.colNum).Image)
Case SftBoxAreaConstants.areaSftBoxLabel
If e.part = SftBoxPortionConstants.partSftBoxDropDown Then
AxSftBox1.DropDown.Suppress() ' Make sure we don't close the drop down
End If
ToggleImage(AxSftBox1.get_Item(e.itemIndex).LabelImage)
Case SftBoxAreaConstants.areaSftBoxItem
If e.part = SftBoxPortionConstants.partSftBoxDropDown Then
AxSftBox1.DropDown.Suppress() ' Make sure we don't close the drop down
End If
If AxSftBox1.get_Item(e.itemIndex).Expandable Then
ExpandCollapseItem(e.itemIndex, e.shift)
Else
ToggleImage(AxSftBox1.get_Item(e.itemIndex).Image)
End If
Case SftBoxAreaConstants.areaSftBoxButton, SftBoxAreaConstants.areaSftBoxCell
If e.part = SftBoxPortionConstants.partSftBoxDropDown Then
AxSftBox1.DropDown.Suppress() ' Make sure we don't close the drop down
End If
ExpandCollapseItem(e.itemIndex, e.shift)
End Select
End Sub
Private Sub AxSftBox1_SelectionChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftBox1.SelectionChange
CopyImageFromCurrentItem()
End Sub