Problem: Non-Rectangular Buttons on a WinCC Flexible 2007 Runtime
WinCC Flexible 2007 and its successor WinCC Comfort ship a single button primitive: a rectangular touch area. The Polygon tool in the Vector graphics palette lets you draw any closed shape — triangle, pentagon, star, arrow — but those vector objects do not raise Click, Press, or Release events, because they are decorative graphics, not controls. When an operator on an MP 277 needs a triangle-shaped increment/decrement control — for example, a numeric editor styled like a spinner — the HMI engineer must layer an event-raising control under or over the visible polygon.
The field-proven workaround is the Invisible Button overlay: a transparent button object placed on top of the polygon, with a rectangular hit zone sized small enough to feel triangular to the operator. The polygon supplies the visible shape; the invisible button supplies the event interface. This is the same pattern used in earlier ProTool/Pro and continues unchanged into the WinCC Flexible 2007 system manual and the Comfort Panel line.
Why Every WinCC Flexible Button Stays Rectangular
Every HMI button in WinCC Flexible 2007 inherits from the Windows CE common control class Button. Touch input on Windows CE resolves to a rectangular bounding box, and the runtime dispatches WM_LBUTTONDOWN / WM_LBUTTONUP only when the touch coordinate falls inside that box. Vector graphics are rendered as GDI+ paths and have no built-in hit-test. There is no property in the WinCC Flexible object model — through SP5 — that turns a polygon into an event-raising control.
You can scale, rotate, recolor, or animate a polygon, but you cannot bind a script to its Press event. This is a documented runtime limitation, not a configuration error, and it is consistent across the MP 177, MP 277, MP 377, and Comfort Panel families. The architectural reason is that the MP 277 operating instructions bind events to control objects, and the GDI+ rendering pipeline only computes hit-tests for rectangles.
Prerequisites and Supported Hardware
| Item | Required Version / Part Number |
|---|---|
| Engineering tool | SIMATIC WinCC Flexible 2007 SP3 or later (ESL license is sufficient for MP 277) |
| Target panel | SIMATIC MP 277 10" Touch (6AV6645-0BB01-0AX0) or 12" Touch (6AV6645-0BE01-0AX0) |
| Alternative panels | MP 177 6" Touch (6AV6642-0BA01-0AX0), MP 377 12" Touch (6AV6644-0BA01-0AX0) |
| Runtime firmware | WinCC Flexible 2007 RT, image V1.4.0 or later |
| Transfer path | Ethernet (RFC1006 / PROFINET) recommended; USB-PPI or MPI supported but slow |
| Project tags | At least one internal Integer tag plus optional Min/Max bound tags |
| User rights | Local administrator on the engineering PC for ActiveX registration |
Confirm the runtime image version on the panel: Start > Settings > Control Panel > OP > Device > Image Version. Images older than V1.3.0 cannot host VBScript reliably and must be reflashed via ProSave before commissioning. VBScript activation in the project settings is mandatory: Project > Properties > Runtime > VBScript runtime version = 5.6.
Building the Triangle Button: Step-by-Step
Step 1 — Create the Project Tags
- Open HMI Tags in the project tree and add a new tag named
CounterValuewith:- Data type:
Int(16-bit signed) - Connection: Internal tag
- Initial value:
0 - Acquisition cycle: 100 ms
- Data type:
- Add
Counter_Min(Int, initial 0) andCounter_Max(Int, initial 100) to bound the spinner range. - Add a hidden Bool
btnInc_PressedandbtnDec_Pressedfor the press-feedback animation in Step 5.
<Internal tag> from the Connection dropdown, not a PLC connection. Internal tags live in panel RAM only and are not exchanged with the controller. This is essential if the spinner is purely a local operator input.Step 2 — Draw the Triangle Polygon
- Open the screen where the spinner will live (e.g.,
Screen_01). - From the toolbox, expand Graphics > Vector graphics and double-click Polygon.
- In the property dialog, click Points... and enter three coordinates relative to the polygon origin:
- Point 1:
0, 80 - Point 2:
80, 80 - Point 3:
40, 0
- Point 1:
- Set Fill color to
0x0066CC(Siemens petrol) and Line color to0x000000. Disable the border by setting Line width to0for a clean filled triangle. - Place the polygon at screen coordinates (320, 200). Resize by dragging the bounding-box handles. The
WidthandHeightproperties in the layout pane must remain consistent with the three points, otherwise GDI+ renders the path scaled and the corners round.
For a downward-pointing (decrement) triangle, mirror the points vertically: 0,0 / 80,0 / 40,80. The two polygons should sit stacked vertically, base-to-base, with a 6 px gap to avoid a false hit zone at the seam.
Step 3 — Drop the Invisible Button
- From the toolbox, expand Controls > Buttons and Switches and select the standard Button object.
- Drop it on top of the polygon and resize it so the rectangular hit zone fits inside the visible triangle:
- X = 322, Y = 215 (offset 2 px inside the base)
- Width = 76, Height = 60
- In the Properties pane, set:
-
Name =
btnIncrement - Text = (empty)
-
Background color =
0xFFFFFF - Transparency = 100% — this is the "invisible" step
-
Border =
None
-
Name =
Step 4 — Bind the VBScript Increment/Decrement
- Right-click
btnIncrement> Properties > Events. - Click the field next to Click and select Add function.... The script editor opens.
- Paste the increment routine:
Sub btnIncrement_Click(ByVal Item) Dim iVal iVal = SmartTags("CounterValue") iVal = iVal + 1 If iVal > SmartTags("Counter_Max") Then iVal = SmartTags("Counter_Max") End If SmartTags("CounterValue") = iVal End Sub - Drop a second invisible button on the mirrored (downward) polygon, name it
btnDecrement, and add:Sub btnDecrement_Click(ByVal Item) Dim iVal iVal = SmartTags("CounterValue") iVal = iVal - 1 If iVal < SmartTags("Counter_Min") Then iVal = SmartTags("Counter_Min") End If SmartTags("CounterValue") = iVal End Sub
The SmartTags dictionary is provided by the WinCC Flexible runtime; it returns and accepts Variant values, so numeric coercion happens automatically. The ByVal Item parameter is required by the runtime — omitting it produces a silent "Subscript out of range" error in rt_trace.log on the first click. The exact handler signature is documented in the WinCC Flexible VBScript reference.
Step 5 — Add Visual Press Feedback
Triangle buttons look flat without feedback. Animate the polygon's Fill color via the animation list bound to a hidden internal Bool tag btnInc_Pressed, toggled by the Press and Release events of btnIncrement:
Sub btnIncrement_Press(ByVal Item)
SmartTags("btnInc_Pressed") = True
End Sub
Sub btnIncrement_Release(ByVal Item)
SmartTags("btnInc_Pressed") = False
End Sub
Configure the animation: Appearance > Fill color > Variable trigger > btnInc_Pressed >= 1 > Color = 0x003366. The triangle darkens while the operator's finger is on it. The same routine applies to btnDecrement with btnDec_Pressed.
Step 6 — Z-Order and Screen Properties
Right-click the polygon > Arrange > Send to Back. The invisible button must stay on top; otherwise the touch event goes to the polygon (no event) and the press registers as a screen-level click. The runtime hit-test always selects the topmost control whose rectangle contains the touch point. If your screen uses Layered screens for navigation, lock the triangle to the foreground layer (Layer 31) so it stays on top when the operator opens a pop-up.
Step 7 — Compile, Transfer, and Verify
-
Project > Compiler > All > Generate. Build status must report
0 errors, 0 warnings; the script editor flags VBScript syntax errors here. - Connect the PC to the MP 277 via Ethernet. On the panel, open Control Panel > Transfer > Ethernet, enable remote control, and tick Transfer mode. From the PC, use Transfer > Ethernet > Accessible Nodes; the panel's MAC should appear within 3 s.
- After transfer, the panel reboots into the start screen. Tap the increment triangle ten times. The bound I/O field must count from 0 to 10. Tap decrement past 0 — the value should clamp at
Counter_Min. - Open the panel's Control Panel > OP > Trace log and search for
btnIncrement. Each click should append aVB script OKline. ASC_ERR_NOT_FOUNDentry means the tag name inSmartTags()is wrong or the connection is missing.
Advanced Variations: Compound Polygons and Animated Spinners
For a hexagon or octagon, replace the three polygon points with six or eight coordinates and size the invisible button to the inscribed rectangle. Hit accuracy drops because the rectangle covers less of the visible area; on a 10" MP 277, keep the rectangle coverage above 70% so the operator does not have to aim at the center of each side.
To make the triangle rotate or pulse, animate the polygon's Rotation property (0–360°) on a 2-second cycle using a hidden internal tag AnimPhase driven by a system scheduler. The invisible button does not rotate with the polygon — re-enter its position so the hit zone stays aligned to the visual center. Animation performance is bounded by the panel's 266 MHz ARM9 CPU; do not animate more than four polygons per screen at full repaint cycle or you will see visible jitter at 30 Hz repaint.
For a numeric up/down spinner with 0.1 step, declare CounterValue as Real and add 0.1 / -0.1 in the script, with a Round() to two decimals to avoid IEEE-754 drift. Note that the MP 277 runtime uses 32-bit floats, so 1,000,000 increment operations still produce a stable value, but 10,000,000 may show the 0.0000001 drift typical of single-precision rounding.
Performance and Memory Considerations
Each invisible button adds roughly 1.2 KB to the compiled HMI runtime, and each VBScript function adds ~600 bytes of p-code. A screen with 20 spinner triangles costs about 36 KB of working memory, well below the MP 277's 128 MB ceiling. The runtime evaluates VBScript in a single-threaded interpreter; a click handler above 200 ms blocks the touch queue. For longer operations, offload to a scheduler-tag state machine and write the result back to CounterValue in the next 100 ms cycle.
| Resource | Per Triangle Button | 20 Triangles | Panel Limit (MP 277 10") |
|---|---|---|---|
| Runtime image footprint | ~1.2 KB | ~24 KB | 64 MB flash, 128 MB RAM |
| Script p-code | ~600 B per handler | ~12 KB | Embedded in HMI binary |
| Touch evaluation latency | ~15 ms | ~20 ms worst case | 100 ms max (HMI spec) |
| Variable cycle time | 100 ms | 100 ms | 100 ms minimum |
Troubleshooting Matrix
| Symptom | Likely Cause | Fix |
|---|---|---|
| Triangle visible but tap does nothing | Polygon is on top of the invisible button | Right-click polygon > Send to Back; verify Z-order in Layout > Tab order view |
| Tap registers, value never changes | Script bound to Release instead of Click, or tag name typo | Re-bind to Click event; cross-check tag name with the HMI Tags list |
| Runtime shows "Type mismatch" popup | CounterValue is Word (unsigned) and assignment exceeds 32767 |
Change tag to Int or DInt; clamp the value with Counter_Max
|
| Faint white rectangle over triangle | Background transparency less than 100% | Properties > Appearance > Transparency = 100% |
| Press feedback animation not visible | Animation list points at wrong tag or wrong condition syntax | Use Value range trigger: btnInc_Pressed >= 1 |
| Counter resets to 0 on screen change | Tag configured as Local, not Retentive | HMI Tags > Properties > Persistence = Retentive; for internal tags also enable Acquisition in the area pointer |
| Script runs in simulation but not on panel | VBScript runtime image V1.2.x on panel | Reflash MP 277 with image V1.4.0 or later via ProSave; back up recipe data first |
| Compile error "Expected: end of statement" | Reserved word used as variable name (e.g., Counter) |
Rename to CounterValue; the reserved-word list is in the WinCC Flexible VBScript reference |
| Click works on panel A but not panel B | Firmware mismatch; one panel runs WinCC Flexible 2005 image | Reflash both panels to the same image version; verify with ProSave OS Update |
| Decrement is fast but increment is slow | CPU saturation from a parallel animation in the same screen | Move the spinner to its own screen, or reduce animation frame rate to 10 Hz |
Migration to TIA Portal and WinCC Comfort
The Invisible Button overlay technique survives the move to TIA Portal V13 and later. In WinCC Comfort and WinCC Advanced, the toolbox still ships a Button object; transparency is in Appearance > Background > Alpha. VBScript is supported in addition to C# (introduced in TIA V14 SP1). Steps 1–7 above transfer verbatim — only the icon for the Polygon tool moved from Graphics > Vector graphics to Graphics > Shapes > Polygon.
For new projects on a TP700 Comfort or TP1500 Comfort, prefer the built-in Symbol Library > Controls > Stepper object, which already implements a non-rectangular up/down control with clamping, configurable step, and Min/Max bindings. The Invisible Button pattern is only needed for legacy MP 177 / MP 277 / MP 377 panels that cannot be migrated to Comfort firmware. The TIA Portal migration guide covers cross-compilation of WinCC Flexible 2007 projects with a 95% auto-conversion rate; the remaining 5% is mostly event-handler signatures and tag-acquisition cycle changes.
Frequently Asked Questions
Can I bind a script directly to a polygon in WinCC Flexible 2007?
No. Vector polygons are decorative objects and have no event interface. You must overlay an invisible button (or an invisible I/O field) to capture the Click, Press, or Release event. The polygon is rendered through GDI+ and is not part of the control hit-test chain.
What is the smallest practical triangle size for a touch target?
Siemens recommends 30 x 30 pixels minimum on the MP 277 10" and 40 x 40 on the 12" panel to meet the EN 60068-2-32 ergonomic guideline for finger-touch accuracy. A 76 x 60 pixel button on top of an 80 x 80 polygon is comfortable for industrial operators wearing gloves; below 40 x 40 the false-touch rate rises sharply with thicker gloves.
Why does the script compile on the engineering PC but not on the panel?
WinCC Flexible supports only a subset of VBScript on the panel. Avoid CreateObject, late binding, file I/O, and Wscript.Shell; they run in the Win32 simulation but throw SC_ERR_NOT_SUPPORTED on Windows CE. The MP 277 runtime image must be V1.4.0 or later for VBScript to be available at all.
How do I make the triangle act as a momentary pushbutton rather than a toggle?
Bind Press to set an internal Bool tag, Release to clear it, and read the Bool from the controller. The visible state is animated off the Bool. WinCC Flexible does not expose a dedicated momentary button class — this Press/Release state machine is the standard workaround.
Can the same invisible button drive multiple PLC tags in one click?
Yes — within a single Click handler you can write to as many SmartTags as needed. Keep the routine under 200 ms because the panel blocks other touch events while the script runs. For longer operations, use the scheduler and a state-machine tag rather than expanding the Click handler, and split the work across two 100 ms scheduler cycles to keep the touch queue responsive.