1. Problem Overview
The WinCC Alarm Control OCX exposes a configurable runtime status bar that includes a live counter for "Number of messages in the window". Engineers frequently need to surface that integer to other application logic — HMI tag mapping, external SCADA handshakes, third-party HMIs, or reporting scripts — without deploying the WinCC Connectivity Pack, WinCC/Performance Monitor, or a separate OPC UA server.
Direct read access to this status-bar element depends entirely on the WinCC version. From V7.0 onward, the Alarm Control COM/ActiveX object exposes properties that return the status-bar element identifier and the displayed text for each configured cell. In WinCC V6.2 SP3 and earlier, those properties are absent from the type library, and the standard scripting interfaces return an "object does not support this property or method" runtime error.
This reference documents the supported property surface per WinCC release, the version-correct way to query the message-count cell, and the field-proven workarounds for legacy V6.2 SP3 deployments.
2. Alarm Control Status Bar Architecture
The runtime status bar of the WinCC Alarm Control is a fixed-element strip whose cells are populated by AlarmControl services during each refresh tick. Three of the most commonly enabled cells, documented in the WinCC V8.0 and V8.1 runtime manuals, are:
| Status Bar Cell | Semantics |
|---|---|
| Number / Current | Number of current messages in the message list. Count includes messages currently hidden by an active filter. |
| Window | Number of messages visible in the current alarm window (after filter is applied). |
| Ackn | Number of pending messages that still require operator acknowledgement. |
Each cell is rendered as a child of the status bar inside the WinCC Alarm Control ActiveX container. The OCX exposes two orthogonal enumerations:
- An element identifier that selects which configured cell is being queried (0..n-1, depending on the status bar layout configured in Graphics Designer).
- The displayed text of that cell, returned as a BSTR.
The official Siemens runtime manual "Working with WinCC (Part 2)", entry ID 109986390, documents the V8.1 implementation; the equivalent V8.0 description is entry 109818253. Both entries explicitly state that the Window cell "Number of messages in the window" excludes the hidden messages retained in the message list.
3. Version Compatibility Matrix
The property surface that makes programmatic access to the Window cell possible is not consistent across releases. Use this matrix before selecting an implementation path.
| WinCC Version | StatusbarElementId | StatusbarElementText | Recommended Access Path |
|---|---|---|---|
| V6.0 / V6.2 (incl. SP3) | Not exposed | Not exposed | Workaround via picture window enumeration or external SQL on archive |
| V7.0 / V7.0 SP1 | Exposed | Exposed | VBScript via HMIRuntime, screenitem, .StatusbarElementId / .StatusbarElementText |
| V7.2 / V7.3 | Exposed | Exposed | VBScript, C/C++ via WinCC ODK, or VB via ActiveX reference |
| V7.4 / V7.5 | Exposed | Exposed | Same as V7.2; full Unicode support |
| V8.0 / V8.1 | Exposed | Exposed | Same as V7.4; 64-bit aware where the OS supports it |
StatusbarElementId or StatusbarElementText. Calling them from a VBS action raises error "Object doesn't support this property or method: 'StatusbarElementId'" (VBScript runtime error 438).4. Reading the Window Cell on WinCC 7.0 and Later (VBScript)
On WinCC V7.0 SP1 and onward, the Alarm Control object is reachable from any VBS action via the standard HMIRuntime path. The reference to the control is obtained through ScreenItems, and the cell content is read by setting StatusbarElementId to the index of the desired cell and reading back StatusbarElementText.
Step 1 — locate the Alarm Control inside the active picture. The control name must match the Object name configured in Graphics Designer (default pattern: Control1, Control2, …).
' VBScript executed in a WinCC Graphics Designer action or global action.
Dim objAlarm
Set objAlarm = HMIRuntime.ActiveScreen.ScreenItems("Control1")
If Not IsObject(objAlarm) Then
HMIRuntime.Trace "AlarmControl not found on active screen" & vbCrLf
Exit Sub
End If
Step 2 — read the status-bar element. The integer literal passed to StatusbarElementId is the 0-based index of the status-bar cell whose order was defined in Graphics Designer (Properties → Status Bar → Elements). To verify which index corresponds to "Number of messages in the window", enable the status bar in the WinCC Alarm Control Configuration dialog and note the cell order.
Dim iCellIndex
Dim sCellText
Dim iMsgCount
iCellIndex = 3 ' <-- confirm against the configured element order
objAlarm.StatusbarElementId = iCellIndex
sCellText = objAlarm.StatusbarElementText
HMIRuntime.Trace "Window cell text = '" & sCellText & "'" & vbCrLf
If IsNumeric(sCellText) Then
iMsgCount = CLng(sCellText)
' iMsgCount now holds the integer to feed into HMI tags,
' archives, or external scripts.
End If
Step 3 — promote the integer into a tag. A common pattern is to write the count into a WinCC tag of type 32-bit signed integer so other HMI pictures or external consumers can read it without re-querying the control.
Dim oTag
Set oTag = HMIRuntime.Tags("AlarmCount_Window")
oTag.Value = iMsgCount
oTag.Write
StatusbarElementId and StatusbarElementText are read-side properties when querying the rendered text. Writing to the displayed text is not supported by WinCC. The Alarm Control is the single source of truth; your application must treat the value as authoritative only inside the Alarm Control refresh cycle.5. Verifying the Element Order
Before trusting the index, query every visible cell once and dump the labels. This eliminates ambiguity when the status bar layout is changed by another integrator.
Dim i
Dim sLabel
For i = 0 To 10
On Error Resume Next
objAlarm.StatusbarElementId = i
sLabel = objAlarm.StatusbarElementText
If Err.Number = 0 And Len(sLabel) > 0 Then
HMIRuntime.Trace "Cell " & i & " -> '" & sLabel & "'" & vbCrLf
Else
Err.Clear
Exit For
End If
Next
The cell whose text is a numeric string and whose label in the status bar reads "Window" is the one you need. Map its index to a project constant and document it in the project archive.
6. Workarounds for WinCC 6.2 SP3 and Earlier
Three field-proven paths exist when StatusbarElementId is not exposed. Choose based on what is already deployed in the plant.
6.1 Picture-window enumeration via Win32 API
The status bar is a Win32 common control that ships inside the Alarm Control window. Use FindWindowEx to traverse the child window chain and read the cell text through the SB_GETTEXT message. This works on V6.0 and V6.2 SP3 because it bypasses the COM surface entirely.
' VBScript on WinCC 6.2 SP3 — relies on a registered Win32 helper DLL
' (e.g., "SbGetText.dll" exposing GetStatusBarText). The helper must be
' registered with regsvr32 and declared via Declare statements.
Private Declare Function FindWindowEx Lib "user32" _
Alias "FindWindowExA" (ByVal hWndParent As Long, _
ByVal hWndChildAfter As Long, ByVal lpszClass As String, _
ByVal lpszWindow As String) As Long
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Const WM_USER = &H400
Const SB_GETTEXT = (WM_USER + 6)
Const SB_GETTEXTLENGTH = (WM_USER + 7)
Dim hWndAlarm As Long
Dim hWndStatus As Long
Dim iLen As Long
Dim sBuf As String
hWndAlarm = HMIRuntime.ActiveScreen.ScreenItems("Control1").Hwnd
hWndStatus = FindWindowEx(hWndAlarm, 0, "msctls_statusbar32", vbNullString)
If hWndStatus <> 0 Then
iLen = SendMessage(hWndStatus, SB_GETTEXTLENGTH, 2, 0)
sBuf = String(iLen + 1, Chr(0))
SendMessage hWndStatus, SB_GETTEXT, 2, sBuf
' sBuf now contains the third (0-indexed = 2) status-bar cell text.
End If
wParam in SB_GETTEXT is the cell index, not the element ID exposed by WinCC 7.0. Confirm the layout empirically on each deployment because V6.2 SP3 cannot introspect the cells programmatically.6.2 C/C++ via WinCC ODK
WinCC ODK (Option Development Kit) is available on V6.2 SP3 and gives C/C++ access to the runtime data model. For sites that already use ODK to read message counts, the same DM_GetMessageList call can be reused instead of touching the status bar at all. The drawback is per-call overhead, so cache the result with a debounce timer.
6.3 Direct query of the message archive via ODBC
The SQL-based alarm logging archive (default database CC_AlarmLogEn) exposes the full MSDATETIME-stamped history. Count rows whose STATE = 1 and COMESFROM = <server> within a sliding window. Use this only when the Alarm Control does not reflect filter-relevant state (e.g., when the operator opened a different picture and the alarm window is not on screen).
7. C/C++ Implementation for WinCC 7.0+
Native C/C++ callers (typically inside custom DLLs loaded by WinCC) obtain the Alarm Control pointer through the WinCC ODK runtime API. Once the ICxAlarmCtrl-style dispatch interface is acquired, the same two properties apply:
// Pseudocode for C++ via the WinCC Alarm Control IDispatch interface.
// Build against the Alarm Control type library distributed with WinCC.
IDispatch* pAlarm = GetAlarmControlFromScreenItem(pPicture, "Control1");
DISPID dispidElementId = 0;
DISPID dispidElementText = 0;
OLECHAR* szElementId = L"StatusbarElementId";
OLECHAR* szElementText = L"StatusbarElementText";
pAlarm->GetIDsOfNames(IID_NULL, &szElementId, 1, LOCALE_USER_DEFAULT, &dispidElementId);
pAlarm->GetIDsOfNames(IID_NULL, &szElementText, 1, LOCALE_USER_DEFAULT, &dispidElementText);
DISPPARAMS dp = {};
VARIANT vIdx; VariantInit(&vIdx); vIdx.vt = VT_I4; vIdx.lVal = 3;
dp.rgvarg = &vIdx; dp.cArgs = 1;
VARIANT vResult; VariantInit(&vResult);
pAlarm->Invoke(dispidElementId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
&dp, nullptr, nullptr, nullptr);
DISPPARAMS dpGet = {};
pAlarm->Invoke(dispidElementText, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
&dpGet, &vResult, nullptr, nullptr);
// vResult.bstrVal contains the displayed cell text.
Always release the IDispatch pointer when the picture unloads. Hook the picture's Closed event from C++ to free the interface and avoid access violations during picture switching.
8. VB (VB6) Implementation
Visual Basic 6 callers can add a reference to the Alarm Control OCX directly. Drop an Alarm Control on a VB6 form, or — for headless queries — instantiate it programmatically.
' VB6 — reference to "WinCC AlarmControl Control" must be set.
Dim objAlarm As New CCAlgWinCtlLib.AlarmControl
objAlarm.StatusbarElementId = 3
Debug.Print objAlarm.StatusbarElementText
StatusbarElementText returns an empty string. Use the existing Alarm Control that is already loaded inside the WinCC picture rather than creating a second instance.9. Performance and Refresh Behavior
The status bar is repainted on every Alarm Control refresh tick (configurable via the Update property in the alarm configuration). Reading the property from VBScript is synchronous and inexpensive; calling it inside a 100 ms cyclic action is well within the budget of any V7.0+ runtime.
| Scenario | Suggested Polling Interval | Notes |
|---|---|---|
| Display-only HMI tag | 500 ms | Sub-perceptible lag for operators |
| External SCADA hand-off via OPC | 1000 ms | Align with OPC update rate |
| Archiving trigger (e.g., snapshot on threshold) | Event-driven | Use Alarm Control MsgCtrlFlags events instead of polling |
For sub-second reactivity, prefer event-driven hooks over polling. WinCC exposes the OnMsgChanged event from the Alarm Control; handle it to push the new count into your downstream tag without a polling loop.
10. Edge Cases and Field-Proven Caveats
-
Empty alarm window. If the Alarm Control has no messages (and no archived messages either), the cell text is the literal "0".
CLng("0")succeeds. Treat zero as a valid value, not an error. - Localized cell labels. The label shown next to the count in the status bar is a localization-dependent string. Do not parse the label text — query the index that you have documented and read the numeric text only.
- Hidden-but-counted messages. The "Number" / "Current" cell includes messages hidden by the active filter; the "Window" cell excludes them. If the operator applied a filter that hides 80% of the active alarms, only the visible 20% are reflected in the Window cell. Confirm which semantics the downstream consumer expects.
-
Picture switching. Calling
HMIRuntime.ActiveScreen.ScreenItems(...)outside the picture that hosts the Alarm Control raises "Invalid object reference" (VBScript error 424). UseHMIRuntime.Screens("PictureName").ScreenItems(...)to target a known picture. -
Multiple Alarm Controls on one picture. Each control exposes its own
StatusbarElementId/StatusbarElementTextpair. Index 3 of Control1 is not the same logical cell as index 3 of Control2 unless both pictures were configured identically. - WinCC 7.0 SP1 vs 7.0 RTM. The first release where the property pair is consistently documented is V7.0 SP1. On V7.0 RTM the type library may exist but the property can return empty strings until the status-bar layout is saved at least once in Graphics Designer.
11. Verification Procedure
- Open WinCC Graphics Designer and confirm the Alarm Control is placed on the picture with the expected Object name (e.g.,
Control1). - Open the Alarm Control Properties dialog → Status Bar tab → Elements. Verify that the cell "Number of messages in the window" is enabled and note its position (1st, 2nd, 3rd, …) from the left.
- Generate the project. In Runtime, open the picture and confirm the cell renders a numeric value.
- Attach a temporary VBS action that dumps all visible status-bar cell texts (the loop from Section 5). Verify the cell index you plan to use actually maps to the Window label.
- Promote the cell value to an internal WinCC tag and display that tag on the same picture using an I/O field. Confirm the value updates when new alarms arrive or are filtered.
- Switch pictures and back. Confirm the count persists or re-acquires correctly — depending on whether the Alarm Control is picture-static or shared.
12. Troubleshooting Matrix
| Symptom | Likely Cause | Remediation |
|---|---|---|
| Error 438: "Object doesn't support this property or method" on StatusbarElementId | Runtime is WinCC V6.x; property not in type library | Upgrade to V7.0 SP1+ or apply the Win32 SB_GETTEXT workaround |
| StatusbarElementText returns empty string | Wrong cell index, or status-bar element not enabled in Graphics Designer | Run the diagnostic loop from Section 5 to enumerate the active cells |
| Value never updates | Polling action uses a 0 ms trigger or runs in a picture without the Alarm Control | Use a 500 ms cyclic trigger and target the correct picture via HMIRuntime.Screens(...)
|
| Value is non-numeric | The index landed on a label cell rather than the count cell | Re-verify cell order; do not assume the same index across projects |
| Value counts hidden alarms (off by a large factor) | You are reading the "Number / Current" cell, not the "Window" cell | Reduce the index by one or document the cell mapping explicitly in the project |
| Crash on picture close | C++ code retained IDispatch* pointer after picture unload |
Hook the picture's Closed event and call Release()
|
13. Related Automation Patterns
Once the count is exposed as a WinCC tag, several downstream patterns become trivial:
-
Threshold-based annunciator panel. Drive a separate overview screen that flashes when
AlarmCount_Window > 0. Combine with the "Ackn" cell count to differentiate unacknowledged storms from acknowledged backlog. - OPC UA export. Publish the count as a WinCC OPC UA tag. External SCADA systems can subscribe at the configured update rate without deploying the Connectivity Pack.
- S7 tag hand-off. Map the WinCC tag to a DBW on the connected S7 PLC. The PLC can then drive physical annunciators or shift production routing based on the unacknowledged count.
14. References in Documentation
- Siemens Online Support ID 109986390 — WinCC V8.1: Working with WinCC, Part 2. Describes the Number, Window, and Ackn status-bar elements.
- Siemens Online Support ID 109818253 — WinCC V8.0: Operation of Alarm Control during Runtime. Same element semantics; useful for cross-version regression checks.
- Siemens Online Support entry WinCC Working with WinCC Part 2 PDF — direct download of the manual cited in ID 109986390.
Frequently Asked Questions
Does WinCC 6.2 SP3 expose the "Number of Messages in the window" value programmatically?
No. WinCC 6.2 SP3 does not publish the StatusbarElementId or StatusbarElementText properties on the Alarm Control type library, so any VBScript call raises runtime error 438 ("Object doesn't support this property or method"). Use a Win32 SB_GETTEXT traversal of the child status-bar window or query the message archive directly via ODBC.
From which WinCC version can I read the Window cell directly with VBScript?
From WinCC V7.0 SP1 onward. Set StatusbarElementId to the configured cell index (typically 0..n-1 in the order defined in Graphics Designer → Status Bar → Elements) and read StatusbarElementText as a BSTR. Convert the returned string to an integer with CLng() when the cell holds a numeric count.
How do I find the correct StatusbarElementId for the Window cell?
Use a one-shot diagnostic loop that queries indices 0..10 and traces the displayed text for each. The cell whose label renders as "Window" (per the V8.0 / V8.1 manuals, IDs 109986390 and 109818253) and whose text is numeric is the target. Document its index in the project constants.
What is the difference between the Number cell and the Window cell?
The Number (or "Current") cell counts every message currently in the message list, including those hidden by an active filter. The Window cell counts only the messages visible in the alarm window after the filter is applied. Both are documented in WinCC V8.0 and V8.1 runtime manuals; pick the one whose semantics match the downstream consumer.
Can I read the Alarm Control Window count from outside WinCC Runtime?
Only if you deploy an additional package such as the WinCC Connectivity Pack, the WinCC Performance Monitor, or a WinCC OPC UA server. The StatusbarElementId/StatusbarElementText properties are only valid from inside the WinCC Runtime process. External consumers should subscribe to a WinCC tag that your VBScript has populated.