Blog

WinCC 7: Disable Global Color Scheme & Global Shadow

WinCC 7: Disable Global Color Scheme & Global Shadow

Have you ever been trying to change the color properties (ex. background color) of an object in WinCC 7, and it just won’t budge? Are you already familiar with the global color scheme property and constantly find yourself turning it off? Are you looking for a better way to customize objects during development without having to change this property all the time?

Well then, I have a solution for you!

The Good Solution

Sure, you can disable global color scheme (and while we’re at it, global shadow) on each object by selecting that object on the screen, selecting “Effects” under the Properties tab, and changing the global color scheme and global shadow to “No.” Now, you can change the properties of that object all you want.

Global color scheme in porta

The Better Solution

Now, if you’re doing any serious development and adding many items to screens, then this individualized property changing gets old pretty quickly. Well, luckily, you can create default properties for items before they are placed on the screen. Select the object you’re going to put on the screen in the item navigator pane. Then, before you place the item, go to “Effects” again, and disable the global color scheme and global shadow.

Now, you can place as many circles as you like without having to change those properties each time.

the better way to disable

This change persists after you close the project and restart your computer, so the project default settings will be there for you the next time you’re ready to continue development.

The Best Solution

The above step is nice and easy, but it suffers from some drawbacks. First, you have to do this for every object type that you’ll be adding (circles, rectangles, I/O Fields, etc.). Second, this setting only applies to the project you’re working on.

So, if you have several projects that you are working on – say if you’re a developer or you have one engineering station for multiple or distributed projects in your plant – then you would need to do this every time you open a different project. If you are ready to be rid of the global color scheme for all projects on your computer, let me introduce you to VBA in WinCC 7.

VBA can be used within WinCC 7 for automatic configuration of the Graphics Designer (create and edit pictures, objects, menus, and dynamics) and other editors (Tag Management, Alarm Logging, etc.). By modifying the Global Template, we can perform a check when an object is created, or a picture is opened to disable the global color scheme and shadow properties.

To open the VBA editor, open Graphics Designer. Then under Tools > Macros, select Visual Basic Editor (or hit Alt + F11).

macros in graphics designer

Once the Visual Basic Editor opens, we will select the Global Template to make our modifications.

VBA editor

To disable the global color scheme and global shadow for objects, add the following code to the Global Template.

Private Sub Document_HMIObjectAdded(ByVal ThisObject As IHMIObject, CancelForwarding As Boolean)

'Any error we recieve will be simply that a device (ex. faceplate) doesn't have these parameters,
'so resume code on an error
On Error Resume Next
ThisObject.GlobalColorScheme.value = False 'Disable global color scheme
ThisObject.GlobalShadow.value = False 'Disable global shadow

End Sub

To disable the global color scheme for pictures, add the following code to the Global Template.

Private Sub Document_Activated(CancelForwarding As Boolean)

'The faceplate editor does not support global color scheme,
'so disregard errors from this
On Error Resume Next
Application.ActiveDocument.GlobalColorScheme.value = False 'Disable global color scheme

End Sub

Save the Global Template, and you are all finished! You can now open/add pictures and add objects to those pictures to test out your additions.

full code in vba

Note: if you only want to make these changes on the project level rather than for your computer, you can add the above code to the Project Template file instead.

From the WinCC 7 Manual: (Working with WinCC/VBA for Automated Configuration/Introduction: Using VBA in WinCC/Organizing VBA Code in a WinCC Project)

manual in wincc instructions

You can reference the help files for more details about what you can do with VBA in WinCC 7.

Learn more about DMC's WinCC Expertise and contact us today to get started on your next project!

Comments

There are currently no comments, be the first to post one.

Post a comment

Name (required)

Email (required)

CAPTCHA image
Enter the code shown above: