GetBackgroundColor2 Method (ActiveX)

Returns the background color value for the specified cell style.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.GetBackgroundColor2(bstrCellStyle)
object

Type: TableStyle

The object this method applies to.

bstrCellStyle

Access: Input-only

Type: String

The cell style name.

Return Value (RetVal)

Type: AcCmColor

The AutoCAD true color object assigned to the background color of the cell style.

Remarks

No additional remarks.

Examples

VBA:

Sub Example_GetBackgroundColor()
    ' This example creates a TableStyle object and sets values for
    ' the style name and other attributes.
    
    Dim dictionaries As AcadDictionaries
    Set dictionaries = ThisDrawing.Database.dictionaries
  
    Dim dictObj As AcadDictionary
    Set dictObj = dictionaries.Item("acad_tablestyle")
  
    ' Get the current TableStyle object
    Dim tableStyle As AcadTableStyle
    Set tableStyle = dictObj.Item(ThisDrawing.GetVariable("CTABLESTYLE"))
  
    Dim colCurrent As AcadAcCmColor, colRowCurrent As AcadAcCmColor, colNoneCurrent As Boolean
    Set colCurrent = tableStyle.GetBackgroundColor(AcRowType.acDataRow + AcRowType.acTitleRow)
    Set colRowCurrent = tableStyle.GetColor(acDataRow)
    colNoneCurrent = tableStyle.GetBackgroundColorNone(AcRowType.acHeaderRow)

    MsgBox "Table colors " & vbLf & _
           "Background ACI value = " & colCurrent.ColorIndex & vbLf & _
           "Row Text ACI value = " & colRowCurrent.ColorIndex & vbLf & _
           "Background None = " & colNoneCurrent
  
    Dim col As AcadAcCmColor
    Set col = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor." & Left(AcadApplication.Version, 2))
    col.SetRGB 0, 0, 255
    tableStyle.SetBackgroundColor AcRowType.acTitleRow, col
    col.SetRGB 255, 0, 0
    tableStyle.SetColor AcRowType.acDataRow, col
    If colNoneCurrent = False Then
        tableStyle.SetBackgroundColorNone AcRowType.acHeaderRow, True
    Else
        tableStyle.SetBackgroundColorNone AcRowType.acHeaderRow, False
    End If
      
    Dim colNew As AcadAcCmColor, colRowNew As AcadAcCmColor, colNoneNew As Boolean
    Set colNew = tableStyle.GetBackgroundColor(AcRowType.acTitleRow)
    Set colRowNew = tableStyle.GetColor(acDataRow)
    colNoneNew = tableStyle.GetBackgroundColorNone(acHeaderRow)

    MsgBox "Table colors " & vbLf & _
           "Background ACI value = " & colNew.ColorIndex & vbLf & _
           "Row Text ACI value = " & colRowNew.ColorIndex & vbLf & _
           "Background None = " & colNoneNew
  
    tableStyle.SetBackgroundColor AcRowType.acTitleRow, colCurrent
    tableStyle.SetColor AcRowType.acDataRow, colRowCurrent
    tableStyle.SetBackgroundColorNone AcRowType.acHeaderRow, colNoneCurrent
    
    MsgBox "Reset the table style back to its original values."
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_GetBackgroundColor()
    ;; This example creates a TableStyle object and sets values for 
    ;; the style name and other attributes.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (setq dictionaries (vla-get-Dictionaries doc))
    (setq dictObj (vla-Item dictionaries "acad_tablestyle"))
    
    ;; Get the current TableStyle object
    (setq tableStyle (vla-Item dictObj (vla-GetVariable doc "CTABLESTYLE")))
      
    (setq colCurrent (vla-GetBackgroundColor tableStyle (+ acDataRow acTitleRow)))
    (setq colRowCurrent (vla-GetColor tableStyle acDataRow))
    (setq colNoneCurrent (vla-GetBackgroundColorNone tableStyle acHeaderRow))

    (alert (strcat "Table colors \n"
		                 "Background ACI value = " (itoa (vla-get-ColorIndex colCurrent)) "\n"
		                 "Row Text ACI value = " (itoa (vla-get-ColorIndex colRowCurrent)) "\n"
		                 "Background None = " (if (= colNoneCurrent :vlax-true) "True" "False")))
  
    (setq col (vlax-create-object (strcat "AutoCAD.AcCmColor." (substr (getvar "ACADVER") 1 2))))
    (vla-SetRGB col 0 0 255)
    (vla-SetBackgroundColor tableStyle acTitleRow col)
    (vla-SetRGB col 255 0 0)
    (vla-SetColor tableStyle acDataRow col)
    (vla-SetBackgroundColorNone tableStyle acHeaderRow (if (= colNoneCurrent :vlax-true) :vlax-false :vlax-true))
  
    (setq colNew (vla-GetBackgroundColor tableStyle acTitleRow))
    (setq colRowNew (vla-GetColor tableStyle acDataRow))
    (setq colNoneNew (vla-GetBackgroundColorNone tableStyle acHeaderRow))
    (alert (strcat "Table colors \n"
		                 "Background ACI value = " (itoa (vla-get-ColorIndex colNew)) "\n"
		                 "Row Text ACI value = " (itoa (vla-get-ColorIndex colRowNew)) "\n"
		                 "Background None = " (if (= colNoneNew :vlax-true) "True" "False")))

    (vla-SetBackgroundColor tableStyle acTitleRow colCurrent)
    (vla-SetColor tableStyle acDataRow colRowCurrent)
    (vla-SetBackgroundColorNone tableStyle acHeaderRow colNoneCurrent)

    (alert "Reset the table style back to its original values.")

    (vlax-release-object col)
)