Option Explicit On 

Imports AxSftBoxLib45
Imports SftBoxLib45
Imports Softelvdm.OLEConvert

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
Friend WithEvents label3 As System.Windows.Forms.Label
Friend WithEvents label2 As System.Windows.Forms.Label
Friend WithEvents SftBox3 As AxSftBoxLib45.AxSftBox
Friend WithEvents SftBox2 As AxSftBoxLib45.AxSftBox
Friend WithEvents SftBox1 As AxSftBoxLib45.AxSftBox
Friend WithEvents label1 As System.Windows.Forms.Label
Friend WithEvents closeButton As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.label3 = New System.Windows.Forms.Label()
Me.label2 = New System.Windows.Forms.Label()
Me.SftBox3 = New AxSftBoxLib45.AxSftBox()
Me.SftBox2 = New AxSftBoxLib45.AxSftBox()
Me.SftBox1 = New AxSftBoxLib45.AxSftBox()
Me.label1 = New System.Windows.Forms.Label()
Me.closeButton = New System.Windows.Forms.Button()
CType(Me.SftBox3, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.SftBox2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.SftBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'label3
'
Me.label3.Location = New System.Drawing.Point(234, 76)
Me.label3.Name = "label3"
Me.label3.Size = New System.Drawing.Size(131, 121)
Me.label3.TabIndex = 13
Me.label3.Text = "Make sure to try the size box that allows you to resize the drop down portion of " & _
"the control!"
'
'label2
'
Me.label2.Location = New System.Drawing.Point(7, 204)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(358, 53)
Me.label2.TabIndex = 12
Me.label2.Text = "Of course you can add multiple columns, headers and all other features to the com" & _
"bo box in your application."
'
'SftBox3
'
Me.SftBox3.Location = New System.Drawing.Point(7, 167)
Me.SftBox3.Name = "SftBox3"
Me.SftBox3.OcxState = CType(resources.GetObject("SftBox3.OcxState"), System.Windows.Forms.AxHost.State)
Me.SftBox3.Size = New System.Drawing.Size(220, 19)
Me.SftBox3.TabIndex = 11
'
'SftBox2
'
Me.SftBox2.Location = New System.Drawing.Point(7, 121)
Me.SftBox2.Name = "SftBox2"
Me.SftBox2.OcxState = CType(resources.GetObject("SftBox2.OcxState"), System.Windows.Forms.AxHost.State)
Me.SftBox2.Size = New System.Drawing.Size(220, 19)
Me.SftBox2.TabIndex = 10
'
'SftBox1
'
Me.SftBox1.Location = New System.Drawing.Point(7, 76)
Me.SftBox1.Name = "SftBox1"
Me.SftBox1.OcxState = CType(resources.GetObject("SftBox1.OcxState"), System.Windows.Forms.AxHost.State)
Me.SftBox1.Size = New System.Drawing.Size(220, 19)
Me.SftBox1.TabIndex = 9
'
'label1
'
Me.label1.Location = New System.Drawing.Point(7, 8)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(220, 68)
Me.label1.TabIndex = 8
Me.label1.Text = "This example shows how you can use SftBox/OCX to display a color selection.  You " & _
"can add any color to the control."
'
'closeButton
'
Me.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.closeButton.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.closeButton.Location = New System.Drawing.Point(292, 8)
Me.closeButton.Name = "closeButton"
Me.closeButton.Size = New System.Drawing.Size(73, 30)
Me.closeButton.TabIndex = 7
Me.closeButton.Text = "Close"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.CancelButton = Me.closeButton
Me.ClientSize = New System.Drawing.Size(372, 257)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.label3, Me.label2, Me.SftBox3, Me.SftBox2, Me.SftBox1, Me.label1, Me.closeButton})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.Text = "Softel vdm, Inc. - Color Sample"
CType(Me.SftBox3, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.SftBox2, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.SftBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

    End Sub

#End Region

'--locate-marker--

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 AxSftBoxLib45.AxSftBox, ByVal Text As String, ByVal color As Color)
    Dim oneCell As SftBoxLib45.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 AxSftBoxLib45.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

End Class