Hide

SftBox/OCX 5.0 - Combo Box Control

Display
Print

Colors Sample (VB.NET)

This sample illustrates using SftBox/OCX for color selection.

The source code is located at C:\Program Files (x86)\Softelvdm\SftBox OCX 5.0\Samples\Visual Studio - VB.NET\Colors\Form1.vb or C:\Program Files\Softelvdm\SftBox OCX 5.0\Samples\Visual Studio - VB.NET\Colors\Form1.vb (on 32-bit Windows versions).

Private Sub closeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closeButton.Click
  Application.Exit()
End Sub

Private Sub AddColor(ByVal box As AxSftBoxLib50.AxSftBox, ByVal Text As String, ByVal color As Color)
    Dim oneCell As SftBoxLib50.SftBoxCell
    Dim addColor As Integer

    addColor = box.Items.Add(Text)          ' add a new item
    oneCell = box.get_Cell(addColor, 0)     ' get the first cell
    oneCell.Image.Height = 13

    If box Is SftBox2 Then
        oneCell.Image.Width = 26
    Else
        oneCell.Image.Width = 13
    End If
    oneCell.Image.SetColorSample(OLECvt.ToOleColor(color), OLECvt.ToOleColor(color.Black)) ' set the cell's color sample
    ' We'll save the color value in the cell's Data property so
    ' we can use the Items.FindCellData method if needed
    oneCell.Data = ColorTranslator.ToWin32(color)
End Sub

Private Sub AddColors(ByVal box As AxSftBoxLib50.AxSftBox)
    AddColor(box, "Black", Color.Black)
    AddColor(box, "Blue", Color.Blue)
    AddColor(box, "Cyan", Color.Cyan)
    AddColor(box, "Green", Color.Green)
    AddColor(box, "Magenta", Color.Magenta)
    AddColor(box, "Red", Color.Red)
    AddColor(box, "White", Color.White)
    AddColor(box, "Yellow", Color.Yellow)
    AddColor(box, "Scroll bar color", Color.FromKnownColor(KnownColor.ScrollBar))
    AddColor(box, "Desktop color", Color.FromKnownColor(KnownColor.Desktop))
    AddColor(box, "Color of the title bar for the active window", Color.FromKnownColor(KnownColor.ActiveCaption))
    AddColor(box, "Color of the title bar for the inactive window", Color.FromKnownColor(KnownColor.InactiveCaption))

    AddColor(box, "Menu background color", Color.FromKnownColor(KnownColor.Menu))
    AddColor(box, "Window background color", Color.FromKnownColor(KnownColor.Window))
    AddColor(box, "Window frame color", Color.FromKnownColor(KnownColor.WindowFrame))
    AddColor(box, "Color of text on menus", Color.FromKnownColor(KnownColor.MenuText))
    AddColor(box, "Color of text in windows", Color.FromKnownColor(KnownColor.WindowText))
    AddColor(box, "Color of text in caption, size box, and scroll arrow", Color.FromKnownColor(KnownColor.ActiveCaptionText))
    AddColor(box, "Border color of active window", Color.FromKnownColor(KnownColor.ActiveBorder))
    AddColor(box, "Border color of inactive window", Color.FromKnownColor(KnownColor.InactiveBorder))

    AddColor(box, "Background color of multiple-document interface (MDI) applications", Color.FromKnownColor(KnownColor.AppWorkspace))
    AddColor(box, "Background color of items selected in a control", Color.FromKnownColor(KnownColor.Highlight))
    AddColor(box, "Text color of items selected in a control", Color.FromKnownColor(KnownColor.HighlightText))
    AddColor(box, "Color of shading on the face of command buttons", Color.FromKnownColor(KnownColor.Control))
    AddColor(box, "Color of shading on the edge of command buttons", Color.FromKnownColor(KnownColor.ControlDark))
    AddColor(box, "Grayed (disabled) text", Color.FromKnownColor(KnownColor.GrayText))
    AddColor(box, "Text color on push buttons", Color.FromKnownColor(KnownColor.ControlText))

    AddColor(box, "Color of text in an inactive caption", Color.FromKnownColor(KnownColor.InactiveCaptionText))
    AddColor(box, "Highlight color for 3D display elements", Color.FromKnownColor(KnownColor.ControlLightLight))
    AddColor(box, "Darkest shadow color for 3D display elements", Color.FromKnownColor(KnownColor.ControlDarkDark))
    AddColor(box, "Second lightest of the 3D colors", Color.FromKnownColor(KnownColor.ControlLight))
    AddColor(box, "Color of text face", Color.FromKnownColor(KnownColor.Control))
    AddColor(box, "Color of text shadow", Color.FromKnownColor(KnownColor.ControlDark))
    AddColor(box, "Color of text in ToolTips", Color.FromKnownColor(KnownColor.InfoText))

    AddColor(box, "Background color of ToolTips", Color.FromKnownColor(KnownColor.Info))
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim index As Integer
    Dim column As Short

    AddColors(SftBox1)
    ' Select "Red"
    SftBox1.Items.FindCellData(ColorTranslator.ToWin32(Color.Red), 0, -1, 0, index, column)
    SftBox1.Items.Selection = index
    ' make sure we get a horizontal scroll bar
    SftBox1.Items.RecalcHorizontalExtent(0)

    AddColors(SftBox2)
    ' Select "Red"
    SftBox2.Items.FindCellData(ColorTranslator.ToWin32(Color.Red), 0, -1, 0, index, column)
    SftBox2.Items.Selection = index
    ' make sure we get a horizontal scroll bar
    SftBox2.Items.RecalcHorizontalExtent(0)

    AddColors(SftBox3)
    ' Select "Red"
    SftBox3.Items.FindCellData(ColorTranslator.ToWin32(Color.Red), 0, -1, 0, index, column)
    SftBox3.Items.Selection = index
    ' make sure we get a horizontal scroll bar
    SftBox3.Items.RecalcHorizontalExtent(0)
End Sub

Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.