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
- Copy-paste the code from this sample into a module in the Visual Basic Editor.
- Run the procedure. The first section of the procedure brings up the style selector with the default background.
- 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
Dim pRgbColor As IRgbColor
Set pRgbColor = New RgbColor
With pRgbColor
.Red = 200
.Green = 90
.Blue = 90
End With
pFill.Color = pRgbColor
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