Use the Style Selector

Created:3/27/2001
Description:

The Style Selector dialog box lets you choose a style item of a specific style class. For example, the BackgroundSelector allows you to choose a background style item. This sample shows you how to bring up the style selector dialog for symbol backgrounds.

How to use:
  1. Copy-paste the code from this sample into a module in the Visual Basic Editor.
  2. Run the procedure. The first section of the procedure brings up the style selector with the default background.
  3. The second section shows you how to set the default background before bringing up the style selector.
Private Sub SelectBackground()
  
  'Bring up the selector with the default background
  ' Create style selector
  Dim pSelector As IStyleSelector
  Set pSelector = New BackgroundSelector
  Dim bOK As Boolean
  Dim pFill As IFillSymbol
  Dim pBackground As ISymbolBackground
  bOK = pSelector.DoModal(Application.hWnd)
  ' Get the selected background
  If (bOK) Then
    Set pBackground = pSelector.GetStyle(0)
    Set pFill = pBackground.FillSymbol
    MsgBox "The CMYK of the chosen background's color is " & pFill.Color.CMYK
  End If
  
  'Set the selected symbol background of the
  'style selector before bringing it up
  ' Create style selector
  Dim pSelector2 As IStyleSelector
  Set pSelector2 = New BackgroundSelector
  Set pBackground = New SymbolBackground
  Set pFill = New SimpleFillSymbol
  pFill.Color = BuildRGB(200, 90, 90)
  pBackground.FillSymbol = pFill
  pSelector2.AddStyle pBackground
  bOK = pSelector2.DoModal(Application.hWnd)
  ' Get the selected background
  If (bOK) Then
    Set pBackground = pSelector2.GetStyle(0)
    Set pFill = pBackground.FillSymbol
    MsgBox "The CMYK of the chosen background's color is " & pFill.Color.CMYK
  End If
End Sub