Object Fill color based on SA colors

I want to develop something in the same style with the SA colors. Every object is filled with an array of 256  colors, for instance a button on the navigation page. The theme can be changed. Using the expression: Theme_Control_GetColorIndex(Button_GetState(DspGetAnCur())) the correct color is shown. Any idea how to copy the fill array colors from one object to another? I don't want to do that manually. I tried using the Graphics Builder Automation by using the following VBA script:

Dim GraphicsBuilder As IGraphicsBuilder2
Dim miOnColors(260)
Dim miOffColors(260)

Sub test()

udfCopyFillArray 1


udfCopyFillArray 0
End Sub

I have a breakpoint before udfCopyFillArray 0. I first select the objecct I want to copy the color array from in the Graphics Builder. After hitting the breakpoint I switch to my new object. Should be the PropertiesFillColourColourGetEx and PropertiesFillColourColourPutEx, but these don't work. Some magic with the citect.pal also I guess.

Sub udfCopyFillArray(iSet As Integer)

Dim iCounter As Integer
Dim iOnColourNo As Integer
Dim iOffColourNo As Integer
Dim iLimit As Integer
Dim iOperator As Integer
Dim iIndex As Integer

Set GraphicsBuilder = New GraphicsBuilder.GraphicsBuilder ' Set a new instance of the Graphics Builder

With GraphicsBuilder

For iCounter = 0 To 255
If iSet = 0 Then
iIndex = iCounter
.PropertiesFillColourColourGet iIndex, iOnColourNo, iLimit, iOperator
miOnColors(iCounter) = iOnColourNo
If iCounter < 20 Then
Debug.Print CStr(iOnColourNo) + "," + CStr(iOffColourNo)
End If
Else
iOnColourNo = miOnColors(iCounter)
.PropertiesFillColourColourPut iCounter, iOnColourNo, iLimit, iOperator
End If
Next
End With

Set GraphicsBuilder = Nothing ' Reset the COM-object

End Sub

Anybody an idea?

Thanks in advance!

Bas

Parents
  • Bradley,

    There was a small error in the VBA code. Mondaymorning is so much better than fridayafternoon! Didn't get the types right. This code works fine:

    Dim GraphicsBuilder As IGraphicsBuilder2
    Dim mlOnColors(260)
    Dim mlOffColors(260)

    Sub test()

    udfCopyFillArray 1

    Sleep 100

    udfCopyFillArray 0
    End Sub



    Sub udfCopyFillArray(iSet As Integer)

    Dim iCounter As Integer
    Dim lOnColourNo As Long
    Dim lOffColourNo As Long
    Dim iLimit As Integer
    Dim iOperator As Integer
    Dim iIndex As Integer


    Set GraphicsBuilder = New GraphicsBuilder.GraphicsBuilder ' Set a new instance of the Graphics Builder

    With GraphicsBuilder

    For iCounter = 0 To 255
    If iSet = 1 Then
    iIndex = iCounter
    .PropertiesFillColourColourGetEx iIndex, lOnColourNo, lOffColourNo, iLimit, iOperator
    mlOnColors(iCounter) = lOnColourNo
    mlOffColors(iCounter) = lOnColourNo
    Else
    lOnColourNo = mlOnColors(iCounter)
    lOffColourNo = mlOffColors(iCounter)
    .PropertiesFillColourColourPutEx iCounter, lOnColourNo, lOffColourNo, iLimit, iOperator
    End If
    Next
    End With

    Set GraphicsBuilder = Nothing ' Reset the COM-object

    End Sub
Reply
  • Bradley,

    There was a small error in the VBA code. Mondaymorning is so much better than fridayafternoon! Didn't get the types right. This code works fine:

    Dim GraphicsBuilder As IGraphicsBuilder2
    Dim mlOnColors(260)
    Dim mlOffColors(260)

    Sub test()

    udfCopyFillArray 1

    Sleep 100

    udfCopyFillArray 0
    End Sub



    Sub udfCopyFillArray(iSet As Integer)

    Dim iCounter As Integer
    Dim lOnColourNo As Long
    Dim lOffColourNo As Long
    Dim iLimit As Integer
    Dim iOperator As Integer
    Dim iIndex As Integer


    Set GraphicsBuilder = New GraphicsBuilder.GraphicsBuilder ' Set a new instance of the Graphics Builder

    With GraphicsBuilder

    For iCounter = 0 To 255
    If iSet = 1 Then
    iIndex = iCounter
    .PropertiesFillColourColourGetEx iIndex, lOnColourNo, lOffColourNo, iLimit, iOperator
    mlOnColors(iCounter) = lOnColourNo
    mlOffColors(iCounter) = lOnColourNo
    Else
    lOnColourNo = mlOnColors(iCounter)
    lOffColourNo = mlOffColors(iCounter)
    .PropertiesFillColourColourPutEx iCounter, lOnColourNo, lOffColourNo, iLimit, iOperator
    End If
    Next
    End With

    Set GraphicsBuilder = Nothing ' Reset the COM-object

    End Sub
Children
No Data