WinCC Grey Out Picture Elements: Parameter Disable via Script

David Krause14 min read
SiemensTutorial / How-toWinCC
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Problem Overview: Greying Out WinCC Picture Parameters

In Siemens WinCC HMI/SCADA projects, operator panels commonly expose a group of parameters as I/O fields or symbolic text fields on a Picture (the WinCC term for a screen). When the design requires that only one parameter in a set of seven be adjustable at any moment, the remaining six fields must remain visible but become inoperable. The visual effect mirrors that of a disabled command button: the field background shifts to a neutral grey tone and the cursor no longer triggers the configured input mechanism, while the displayed value continues to update from the underlying tag.

The challenge is producing this behaviour on parameter elements that are not buttons — particularly on standard I/O fields and symbolic text fields where the runtime does not expose a built-in toggle identical to a command button's Operator-Control Enable. Two distinct approaches resolve the issue across WinCC V7 (Classic), WinCC Runtime Advanced (TIA Portal), and WinCC Runtime Professional (TIA Portal):

  1. Set the Operation property of the I/O field to No and switch the BackColor to a defined grey RGB constant. The element remains on screen but accepts no operator input.
  2. Use a VBScript or C script procedure invoked from a button-click, value-change, or picture-open event to iterate over a known set of items on the Picture and toggle each item's Operation and BackColor attributes dynamically.

This article documents both approaches with field-tested code samples, parameter tables, version compatibility notes, and a troubleshooting matrix that addresses the most common script errors encountered during commissioning.

Prerequisites and WinCC Environment

Software and Runtime Versions

Component Supported Versions Notes
WinCC V7 (Classic) V7.4 SP5 / V7.5 SP2 or later Full C scripting and VBScript support
WinCC Runtime Advanced (TIA Portal) V15.1 / V16 / V17 / V18 / V19 VBScript only; Comfort and Advanced Panels
WinCC Runtime Professional (TIA Portal) V15.1 / V16 / V17 / V18 / V19 VBScript and C runtime; PC Runtime
WinCC Unified (TIA Portal) V16 / V17 / V18 / V19 / V20 JavaScript API differs; see separate section
STEP 7 / TIA Portal Engineering Matches target WinCC version Configuration software

Hardware Targets

  • SIMATIC Comfort Panels: TP700, TP900, TP1200, TP1500, TP1900, TP2200
  • SIMATIC Advanced Panels: KTP400, KTP700, KTP900, KTP1200
  • SIMATIC IPC series for PC Runtime
  • Standard Windows 10/11 PC stations running Runtime Professional

Licensing

  • WinCC V7: Engineering license + Runtime license (RC 1024 / 8192 / 65536 tags)
  • Runtime Advanced: Panel-specific license embedded in panel firmware
  • Runtime Professional: ES + RT 128 / 512 / 2048 / 4096 tags
  • WinCC Unified: ES + RT 500 / 1500 / 5000 / 10 000 / 50 000 / 100 000 PowerTags

Picture Element Naming Requirements

Each parameter field must carry a unique object name. Adopt a deterministic naming convention such as IOField_1, IOField_2, ..., IOField_7. The naming convention lets the script locate elements through the ScreenItems collection without relying on the object's display position. For faceplate-based panels, propagate the parameter index through the faceplate tag interface.

Static Configuration: Set the Operation Property Manually

The simplest approach disables the field at configuration time. Open the I/O field properties dialog in the Graphics Designer (WinCC V7) or the HMI screen editor (TIA Portal). Navigate to Properties > Miscellaneous and set the Operation property to No. To match the visual appearance of a disabled button, change Background > BackColor to a grey RGB constant such as RGB(192, 192, 192).

This static approach is suitable when the disabled state never changes at runtime — for example, when only an engineer password unlocks the field. When the disabled state must toggle based on operator input, use the dynamic VBScript approach documented in the next sections.

Dynamic Approach: VBScript for Individual Parameter Disabling

Trigger the Script on Button Click

Configure a button on the Picture and assign a Click event. From the event list, select VB Script (or C Script in WinCC V7). Paste the following VBScript as the procedure body:

Sub OnClick(ByVal Item)
    Dim sScreenPath, sItemName
    Dim intSelected
    Dim i
    
    sScreenPath = "MainPicture"     ' Replace with the actual Picture name
    intSelected = 3                 ' Selected parameter index 1..7
    
    For i = 1 To 7
        sItemName = "IOField_" & i
        Dim objItem
        Set objItem = HMIRuntime.Screens(sScreenPath).ScreenItems(sItemName)
        
        If i = intSelected Then
            objItem.Operation = True
            objItem.BackColor = RGB(255, 255, 255)
        Else
            objItem.Operation = False
            objItem.BackColor = RGB(192, 192, 192)
        End If
    Next
End Sub

The loop binds the parameter count (1 to 7) to the naming convention (IOField_1 through IOField_7). The Operation property is exposed by I/O field, text field, and symbolic I/O field objects.

The Operation property is exposed by I/O field, text field, and symbolic I/O field objects. Symbolic I/O fields in TIA Portal use the property OperatorControl or Enabled depending on the runtime version. Verify the exact property name under TIA Portal Help > Screen Object Properties.

Runtime Advanced Variant for Comfort Panels

In WinCC Runtime Advanced, the script interface uses the same HMIRuntime.Screens namespace. The selected index is typically read from an HMI tag rather than a literal constant:

Sub Click(ByVal Item)
    Dim i, objItem
    
    For i = 1 To 7
        Set objItem = HMIRuntime.Screens("MainPicture").ScreenItems("IOField_" & i)
        
        If i = SmartTags("TagSelectedParam") Then
            objItem.OperatorControl = True
            objItem.BackColor = RGB(255, 255, 255)
        Else
            objItem.OperatorControl = False
            objItem.BackColor = RGB(192, 192, 192)
        End If
    Next
End Sub

Another control writes the operator's selected parameter index to TagSelectedParam. The Click event on the I/O field or a dedicated selection button updates the tag, and the procedure re-evaluates all seven fields.

Generic Loop Routine: Iterating the ScreenItems Collection

To avoid hard-coding the seven I/O field names, iterate over the ScreenItems collection. The collection supports the standard For Each loop in VBScript:

Sub GrayOutAllExcept(ByVal sScreenName, ByVal sSelectedItem)
    Dim objScreen, objItem
    Set objScreen = HMIRuntime.Screens(sScreenName)
    
    For Each objItem In objScreen.ScreenItems
        If TypeName(objItem) = "HMIIOField" Or TypeName(objItem) = "HmiTextField" Then
            If objItem.Name = sSelectedItem Then
                objItem.Operation = True
                objItem.BackColor = RGB(255, 255, 255)
            Else
                objItem.Operation = False
                objItem.BackColor = RGB(192, 192, 192)
            End If
        End If
    Next
End Sub
The TypeName function returns class identifiers such as HMIIOField, HmiTextField, HmiButton, and HmiGraphicView. The exact strings depend on the WinCC version. Reference the WinCC Object Model in the Help system under ScreenItems Collection.

Inline SVG Flow Diagram

Operator taps IOField_n Click event fires Script reads selected index From tag or literal Loop i = 1..7 Enumerate ScreenItems i <> selected Operation = False BackColor = RGB(192,192,192) i == selected Operation = True BackColor = RGB(255,255,255) Continue loop

Passing the Picture Name as a Parameter

Sub UpdateParameterStates(ByVal sScreenName, ByVal intSelected)
    Dim i, objItem
    
    For i = 1 To 7
        Set objItem = HMIRuntime.Screens(sScreenName).ScreenItems("IOField_" & i)
        
        If i = intSelected Then
            objItem.Operation = True
            objItem.BackColor = RGB(255, 255, 255)
        Else
            objItem.Operation = False
            objItem.BackColor = RGB(192, 192, 192)
        End If
    Next
End Sub

Call this routine from any event handler on any picture:

Sub OnClick(ByVal Item)
    UpdateParameterStates "MainPicture", 3
End Sub

For pop-up screens launched through the OpenScreenInPopup or picture-window mechanism, pass the active screen name via HMIRuntime.BaseScreenName or the picture-window's ScreenName property.

Alternative: Semi-Transparent Overlay Box

Another engineering pattern is to overlay a rectangle (or graphic view) on top of the parameter group with a semi-transparent fill. The overlay blocks mouse input to the underlying fields and produces an immediate visual grey effect. Implementation steps:

  1. Add a Rectangle object to the Picture and size it to cover the parameter group bounding box.
  2. Set the rectangle's BackColor to RGB(200, 200, 200) and apply a transparency attribute of approximately 50 percent through the colour palette transparency slider.
  3. Place the rectangle on the topmost z-order layer (right-click > Bring to Front).
  4. Show or hide the rectangle via objRect.Visible = True/False in the script.

The advantage is no per-element loop and immediate coverage of any new fields placed under the rectangle. The disadvantage is that the rectangle intercepts all clicks, so the selection button must reside outside the rectangle's area, or the rectangle must allow click-passthrough in Runtime Advanced (set Operator-Control Enable = No on the rectangle).

Color Reference: BackColor RGB Values

State RGB Value Hex Typical Usage
Enabled RGB(255, 255, 255) #FFFFFF Standard white background
Disabled (light grey) RGB(192, 192, 192) #C0C0C0 Common greyed state across editions
Disabled (WinCC V7 default) RGB(214, 214, 214) #D6D6D6 Default disabled field background in WinCC V7
Read-only accent RGB(232, 232, 232) #E8E8E8 Light accent grey for read-only values
Out-of-range highlight RGB(255, 192, 192) #FFC0C0 Error or limit-violation highlight
Focus accent RGB(255, 255, 200) #FFFFC8 Active field cursor highlight

The RGB values must match the project colour palette defined in the Graphics Designer. Use the Tools > Customise > Colour Palette dialog to centralise custom colours and keep references consistent between design-time and runtime.

WinCC Version Compatibility Matrix

Property / Feature WinCC V7 Runtime Advanced (TIA) Runtime Professional (TIA) WinCC Unified
Operation Yes (I/O field, text field) Yes (OperatorControl) Yes (OperatorControl) N/A — use Enabled
Enabled Yes (buttons) Yes Yes Yes
BackColor Yes Yes Yes Yes
Visible Yes Yes Yes Yes
HMIRuntime.Screens Yes Yes Yes Different API
ScreenItems collection Yes Yes Yes Items collection
VBScript support Yes Yes Yes No
JavaScript support No No No Yes
C script support Yes No Yes No
Tag triggering SmartTag / Tag SmartTags(...) SmartTags(...) Tags(...)

C Script Equivalent for WinCC V7

WinCC V7 also supports ANSI-C scripts. The equivalent routine uses SetPropBOOL to flip Operation and SetBackColor via the dynamic dialog function set:

// WinCC V7 - C Script
#include "apdefap.h"

void GrayOutParameters(const char* lpszPictureName, int nSelectedIndex)
{
    int i;
    char szItemName[32];
    
    for (i = 1; i <= 7; i++)
    {
        sprintf(szItemName, "IOField_%d", i);
        
        if (i == nSelectedIndex)
        {
            SetPropBOOL(lpszPictureName, szItemName, "Operation", TRUE);
            SetBackColor(lpszPictureName, szItemName, CO_RGB(255, 255, 255));
        }
        else
        {
            SetPropBOOL(lpszPictureName, szItemName, "Operation", FALSE);
            SetBackColor(lpszPictureName, szItemName, CO_RGB(192, 192, 192));
        }
    }
}

C scripts require the include header apdefap.h and the runtime function library distributed with WinCC V7. Documented APIs include SetPropBOOL, GetPropBOOL, SetBackColor, and SetForeColor for colour manipulation.

WinCC Unified JavaScript Equivalent

WinCC Unified uses a JavaScript-based runtime API. The property Enabled replaces Operation, and the screen object is accessed through the Screen module:

// WinCC Unified V19+ - JavaScript
export function Click_Trigger_1(item) {
    let screen = Tags("ScreenNumber").Read();
    let selected = Tags("TagSelectedParam").Read();
    
    for (let i = 1; i <= 7; i++) {
        let ioField = Screen.FindItem("IOField_" + i);
        if (i === selected) {
            ioField.Enabled = true;
            ioField.BackColor = 0xFFFFFFFF; // ARGB white
        } else {
            ioField.Enabled = false;
            ioField.BackColor = 0xFFC0C0C0; // ARGB grey
        }
    }
}

WinCC Unified uses ARGB colour encoding (alpha + RGB). The alpha channel supports the semi-transparent overlay pattern directly without a separate transparency slider.

Verification Steps

  1. Compile the project in the Engineering Station and download it to the target panel or start the PC Runtime.
  2. Navigate to the picture containing the parameter group.
  3. Verify the initial state: all seven fields appear in their default colour, and only the configured active field accepts operator input.
  4. Tap a different field. The previously active field should grey out (BackColor = RGB(192,192,192), Operation = False), and the newly tapped field should accept input.
  5. Check the WinCC diagnostic window (WinCC V7) or the HMI trace (TIA Portal) for any script errors. Common errors include Object doesn't support this property or method when the property name does not match the runtime version.
  6. Confirm that the back colour persists across picture changes. WinCC resets runtime properties when a picture is closed and reopened. Re-apply the property in the Picture Open event by reading a persistent tag (TagSelectedParam) and updating the BackColor accordingly.
  7. Test edge cases: parameter index out of range (0 or 8), non-existent screen name, empty parameter set, picture change while a script is mid-loop.
  8. Verify that the script does not produce screen flicker by avoiding BackColor updates from a high-frequency tag-change event.

Performance Considerations

Pattern Typical Execution Time (TP1200) Notes
Direct name reference (IOField_1..7) < 5 ms Recommended; explicit object names minimise traversal cost
For Each over ScreenItems 10-40 ms (depending on object count) Use TypeName filter to narrow iteration
Tag-driven refresh on 100 ms cycle Visible flicker Move logic to Click event; avoid tag-driven BackColor updates
Recursive script calls Risk of runtime freeze Never call the routine from a Value Change event of a tag the routine also writes

For pictures with hundreds of screen objects, prefer explicit name references over enumeration. For pictures with ten or fewer items, enumeration is acceptable and yields more maintainable code.

Troubleshooting Matrix

Symptom Root Cause Fix
Object doesn't support this property or method Property name mismatch (Operation vs OperatorControl vs Enabled) Check TIA Portal Help > Screen object properties for the target runtime
All fields stay white Picture name passed to HMIRuntime.Screens is wrong Open the picture on the panel and read the actual picture name from WinCC Explorer / HMI tags
Script error on first element Item name does not match ScreenItems collection Verify the I/O field name in Graphics Designer; rename with the IOField_n convention
Only one field greys For loop bound wrong (off-by-one) Change loop bound to match the actual parameter count (1 to N)
BackColor change has no effect Global colour palette overrides local setting Set BackColor via a dynamic dialog instead of static colour palette; or disable palette inheritance
Script fires only once Script attached to wrong event (Once on click vs Always) Set the trigger event to Click (always) instead of Click (once)
Performance is slow on large pictures Loop iterates all items in ScreenItems (hundreds of objects) Filter by TypeName first; use explicit name references for small parameter sets
Runtime freezes when script runs Infinite loop or recursive event trigger Add a guard flag; never call the routine from a Value Change event of a tag the routine also writes
Property change lost after picture change Picture reset on close Re-apply the property in the Picture Open event using a persistent tag
VBScript syntax error in WinCC Unified WinCC Unified does not support VBScript Rewrite the routine in JavaScript using the Unified Screen / Tags API

Best Practices for Commissioning

  • Naming convention: Prefix all parameter elements with a common identifier (param_ or IOField_) so the script can iterate deterministically without relying on visual position.
  • Event selection: Attach the script to a discrete event (button Click) rather than a periodic tag update, to avoid runtime overhead and screen flicker.
  • BackColor stability: Avoid animations that reapply BackColor every cycle; this causes visible flicker and increases CPU load on Comfort Panels.
  • Read-only display: For elements that should remain visible but never accept input, set Operation = False and skip the loop entirely with a single static configuration.
  • Audit trail: Log the operator's parameter selection to a tag with a timestamp; this supports GxP / CSV-regulated environments and traceability audits.
  • Migration verification: When migrating a project from WinCC V7 to TIA Portal, the property Operation may map to OperatorControl or Enabled depending on the target panel. Verify each screen object after migration with the project diff tool.
  • Style templates: Use the TIA Portal Style template feature (WinCC Unified) or the WinCC V7 style editor to centralise the enabled/disabled colour palette across all parameter panels.

Migration from WinCC V7 to TIA Portal

WinCC V7 Property TIA Portal Runtime Advanced TIA Portal Runtime Professional WinCC Unified
Operation (BOOL) OperatorControl (BOOL) OperatorControl (BOOL) Enabled (BOOL)
BackColor (LONG) BackColor (LONG, RGB) BackColor (LONG, RGB) BackColor (UINT32, ARGB)
HMIRuntime.Screens("X") HMIRuntime.Screens("X") HMIRuntime.Screens("X") Screen.FindItem("X")
ScreenItems collection ScreenItems collection ScreenItems collection Items collection
VBScript (VB Script) VBScript (VB Script) VBScript (VB Script) JavaScript
C Script Not supported C Script Not supported

After migration, recompile the project and test each parameter panel. The TIA Portal Project > Compile > Software (all) tool reports unused references and obsolete API calls. Pay special attention to CO_RGB macro calls in C scripts — these require manual conversion to RGB literals when migrating to Runtime Advanced.

Documentation References

Siemens official WinCC documentation is published through the Siemens Industry Online Support portal. Search the portal for "WinCC V7.5 manual", "WinCC Runtime Advanced manual", "WinCC Unified V19", and "WinCC scripting reference". The WinCC object model (HMIRuntime, Screens, ScreenItems) is documented in the WinCC Information System help installed with the engineering software.

FAQ

How do I grey out a non-button element in a WinCC picture?

Set the element's Operation property to False and change the BackColor to RGB(192, 192, 192). The element remains visible but accepts no operator input. In TIA Portal Runtime, the equivalent property is OperatorControl on I/O fields and Enabled on buttons.

Can I pass a Picture object as a parameter to a WinCC VBScript?

VBScript does not expose a Picture object type. Pass the picture name as a string and access the picture via HMIRuntime.Screens(sPictureName).ScreenItems(sItemName). This pattern works in WinCC V7, Runtime Advanced, and Runtime Professional.

What is the difference between Operation and Visible?

Operation disables input while keeping the element on screen. Visible hides the element completely. To grey out an element, use Operation = False; do not toggle Visibility unless the design intent is to remove the element from view.

Why does the BackColor change not persist after navigating away?

WinCC resets runtime properties when a picture is closed and reopened. Re-apply the property in the Picture Open event by reading a persistent tag (for example, TagSelectedParam) and updating the BackColor accordingly.

Is there a built-in "operator enable" property on WinCC I/O fields?

Yes. The Operation property on I/O fields and the Enabled property on buttons control operator access. Setting either to False produces the greyed-out visual effect and blocks operator input. There is no separate "greyed out" boolean; the visual effect is achieved through the combination of Operation = False and a grey BackColor value.

Does this technique work on WinCC Unified (V19+)?

Yes, but the API is JavaScript-based. Use Screen.FindItem("IOField_n").Enabled = true/false and set BackColor using ARGB encoding. The high-level pattern (loop over items, toggle state) is identical; only the property names and syntax differ.

Back to blog