Overview
In a Siemens PCS 7 OS runtime, an analog input I/O field opened by the standard block icon or by openfaceplateV6() triggers a child picture (the faceplate or RawAnalogInput dialog) that the OS host places using internal defaults. On multi-monitor installations, on touch panels with limited resolution, or when the parent picture is anchored near the bottom of the screen, the dialog can appear underneath the I/O field, off-screen, or hidden behind another window. This forces the operator to either drag the dialog into view, scroll the parent picture, or resize the OS window before the parameter can be edited.
This reference covers four field-proven methods to control where the analog input dialog opens in PCS 7 V7.1 SP1 and later V8.x/V9.x projects:
- Setting the Default Position property on the APL block icon instance (recommended, lowest risk).
- Overriding the dialog position with C functions
SetLeft()andSetTop()inside a project-wide C action. - Replacing the C action with an equivalent VBScript using
objScreenItemspositioning properties. - Activating the Adapt Picture runtime option so the OS workspace auto-resizes the dialog to fit the visible area.
All four approaches are compatible with the PCS 7 OS authorization model and operate without modifying Siemens-delivered standard scripts.
Prerequisites
| Item | Required Value |
|---|---|
| PCS 7 version | V7.1 SP1 minimum; tested on V8.0, V8.2, V9.0 SP2 |
| WinCC Explorer | Installed on the OS engineering station |
| APL library | PCS 7 APL Library V7.1+; block icons compiled in the master data library |
| Graphics compiler | Run after any change to block icon defaults |
| Operator authority | Level 5 (operator) for the relevant tag, enforced by PCS7_CheckPermission
|
| Display target | Resolution matched between ES configuration and OS runtime (1280x1024, 1920x1080, 1920x1200 typical) |
Verify that the OS runtime is fully started and that the faceplate you intend to relocate is the standard APL faceplate (not a customized variant) before changing scripts. Customized faceplates store their own Open position logic in OpenFaceplate callbacks and override global changes.
WinCC Faceplate Architecture
The analog input dialog originates from the standard APL block CH_AI (or MOT_SPEED, CTRL_PID, depending on the signal class). When the operator clicks an I/O field, the block icon dispatches the C function openfaceplateV6(). The function inspects the source object name, looks up the matching faceplate type in the FaceplateDesigner registry, and instantiates a child picture window at the default screen origin.
The openfaceplateV6() implementation is located in the project-level C script set, under Project Functions > Standard Functions > openfaceplateV6. The body of this function is normally inherited from the APL master and should not be edited. To control position you must intervene either:
- before the call returns (wrap the call in your own C action), or
- by setting per-instance defaults on the block icon itself.
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
BOOL bOperation5;
char* lpszTag;
char* lpszStructureIdentifier;
// Extract the tag linked to the I/O field
lpszTag = GetLinkedVariable(lpszPictureName, lpszObjectName, "Tag");
// If the tag is part of a structure, enforce operator authorization
lpszStructureIdentifier = strstr(lpszTag, ".");
if (lpszStructureIdentifier)
{
bOperation5 = PCS7_CheckPermission(lpszTag, 5);
if (!bOperation5)
{
MessageBox(NULL,
"Error: User does not have authorization to edit this tag value.",
"Error",
MB_OK|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
return;
}
}
// Standard APL call to open the Raw Analog Input dialog
Common_OpenRawAnalogInput(lpszPictureName, lpszObjectName);
}
The functions referenced are part of the PCS 7 project API; their declarations are auto-generated when WinCC compiles the project. GetLinkedVariable reads the configured tag from the picture object; PCS7_CheckPermission evaluates WinCC User Administrator rights for the configured area (here, operation level 5).
Approach 1: Per-Instance Default Position on the APL Block Icon
This is the cleanest solution because it does not require any script modification. The APL block icon exposes a Position property group:
| Property | Meaning | Default |
|---|---|---|
| Use default position | If Yes, OS uses internal default coordinates (top-left of the screen) | Yes |
| Position X (pixels) | Horizontal origin of the faceplate in the parent picture coordinate system | 0 |
| Position Y (pixels) | Vertical origin of the faceplate in the parent picture coordinate system | 0 |
| Window mode | TopMost, Standard, or Behind | Standard |
Steps:
- Open the picture containing the I/O field in Graphics Designer.
- Double-click the I/O field to open its configuration dialog.
- Switch to the Block Icon tab (the tab name varies between APL versions: Properties in V7.1, Block Icon in V8.x/V9.x).
- Set Use default position to No.
- Enter Position X and Position Y in pixels. Coordinates are relative to the picture origin (0,0 = top-left of the parent picture).
- Compile and download the OS.
Approach 2: Override Position with C Functions SetLeft and SetTop
When the I/O fields are positioned dynamically at runtime (for example, by a layout script that arranges control groups based on the picture size), per-instance defaults cannot cover every case. The C functions SetLeft and SetTop reposition the dialog after Common_OpenRawAnalogInput returns. Because the dialog is a child picture window, the position is enforced on the picture object rather than on the faceplate type.
Replace the body of Common_OpenRawAnalogInput (or the original OnClick action) with:
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
BOOL bOperation5;
char* lpszTag;
char* lpszStructureIdentifier;
lpszTag = GetLinkedVariable(lpszPictureName, lpszObjectName, "Tag");
lpszStructureIdentifier = strstr(lpszTag, ".");
if (lpszStructureIdentifier)
{
bOperation5 = PCS7_CheckPermission(lpszTag, 5);
if (!bOperation5)
{
MessageBox(NULL,
"Error: User does not have authorization to edit this tag value.",
"Error",
MB_OK|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
return;
}
}
// Open the standard Raw Analog Input dialog
Common_OpenRawAnalogInput(lpszPictureName, lpszObjectName);
// Reposition the dialog 200 px from left, 150 px from top
// Adjust lTop / lLeft for your screen geometry
long lLeft = 200;
long lTop = 150;
SetLeft(lpszPictureName, lpszObjectName, lLeft); // return BOOL
SetTop(lpszPictureName, lpszObjectName, lTop); // return BOOL
}
Function signatures per the WinCC scripting reference:
| Function | Prototype | Return |
|---|---|---|
| SetLeft | BOOL SetLeft(LPCTSTR lpszPictureName, LPCTSTR lpszObjectName, long lLeft) | TRUE on success |
| SetTop | BOOL SetTop(LPCTSTR lpszPictureName, LPCTSTR lpszObjectName, long lTop) | TRUE on success |
| SetWidth | BOOL SetWidth(LPCTSTR lpszPictureName, LPCTSTR lpszObjectName, long lWidth) | TRUE on success |
| SetHeight | BOOL SetHeight(LPCTSTR lpszPictureName, LPCTSTR lpszObjectName, long lHeight) | TRUE on success |
The position values are in screen pixels of the OS runtime window. If the OS is configured for a 1920x1080 panel, lTop = 150 places the dialog 150 px below the workspace top. To anchor relative to the parent I/O field instead of the screen, calculate the offset using GetLeft and GetTop:
long lOriginX = GetLeft(lpszPictureName, lpszObjectName);
long lOriginY = GetTop(lpszPictureName, lpszObjectName);
SetLeft(lpszPictureName, lpszObjectName, lOriginX - 200);
SetTop(lpszPictureName, lpszObjectName, lOriginY - 150);
SetLeft/SetTop with negative coordinates is valid; the dialog will then extend past the left/top edge. On single-monitor systems, keep both values >= 0 to avoid a clipped dialog.Approach 3: VBScript Equivalent
Projects migrated from C to VBS (default in PCS 7 V8.2+) need a VBScript equivalent. Use HMIRuntime.Screens and ScreenItems for the dialog:
Sub OnClick(ByVal Item)
Dim lpszTag
Dim bAuth
lpszTag = Item.GetLinkedVariable("Tag")
' Authorization check for structured tags
If InStr(lpszTag, ".") > 0 Then
bAuth = PCS7_CheckPermission(lpszTag, 5)
If Not bAuth Then
MsgBox "Error: User does not have authorization to edit this tag value.", _
vbExclamation + vbSystemModal, "Error"
Exit Sub
End If
End If
' Open standard dialog
Common_OpenRawAnalogInput Item.Parent.Parent.PictureName, Item.ObjectName
' Reposition the dialog window
Dim dlg
Set dlg = HMIRuntime.Screens(Item.Parent.Parent.PictureName).ScreenItems(Item.ObjectName)
dlg.Left = 200
dlg.Top = 150
End Sub
VBScript exposes .Left, .Top, .Width, .Height directly as properties. Numeric values are in pixels. The Item.ObjectName resolves to the same object referenced by the C function, so the dialog can be moved as soon as the standard call returns.
Approach 4: Adapt Picture Runtime Setting
Activating Adapt Picture instructs the WinCC runtime to scale the entire workspace picture to the OS window client area. The analog input dialog, being a child picture, is then scaled automatically, removing the need for fixed pixel coordinates. Configuration path:
- In WinCC Explorer on the OS, right-click the OS server node and choose Properties.
- Open the Startup tab (or Runtime in V8.x).
- Enable the option Adapt picture to window size.
- Also enable Adapt to screen resolution under Computer properties > Graphics.
- Restart the OS runtime.
Adapt Picture is a global setting and affects every picture in the project. Use it only when the OS target resolution is unknown at engineering time or when the project will be deployed to multiple panel sizes.
Implementation Procedure
-
Identify the analog input source. Use WinCC Information System (Tools > Cross References) to locate every instance of the I/O field that calls
Common_OpenRawAnalogInput. - Choose the approach. Per-instance default for static layouts; SetLeft/SetTop for dynamic; VBS for new projects; Adapt Picture for variable-resolution panels.
- Edit the action. In Graphics Designer, double-click the I/O field, switch to the Events tab, and replace the Click action. Use the project function path (not the master data library) to avoid changes being overwritten on OS download.
- Recompile the OS. Open the OS Project Editor and run Compile OS > All. Watch for C compile errors in the diagnostic output.
- Download to the OS target. Use OS Download > Complete download for the first change; delta download is sufficient thereafter.
- Verify in runtime. Click each I/O field. The dialog should open at the configured coordinates and remain visible without scrolling.
Verification
| Check | How to Verify | Expected Result |
|---|---|---|
| Compile success | WinCC Explorer > OS Project Editor > Output | 0 errors, 0 warnings for the modified action |
| Runtime click | Click I/O field at OS | Dialog opens at configured (lLeft, lTop) |
| Authorization | Log in as a user without area privilege 5 | MessageBox appears, dialog does not open |
| Touch test | Click the I/O field on a touch panel | Dialog visible within panel bounds, no clipping |
| Resolution swap | Change OS resolution, restart runtime | Dialog still readable; Adapt Picture scales correctly |
Add the modified action to your project regression checklist so future APL library updates do not silently revert it.
Troubleshooting Matrix
| Symptom | Likely Cause | Corrective Action |
|---|---|---|
| Dialog still appears at top-left after SetLeft/SetTop | Action recompile missed; old binary in OS cache | Run full OS download, restart WinCC runtime, clear GSC folder |
| Compile error C2065: 'SetLeft' undeclared | Missing #include "apdefap.h" at top of action |
Add include directive; verify apdefap.h is in project pas folder |
| Dialog flashes then returns to default position | Another OnClick action calls openfaceplateV6 after SetLeft | Search for redundant actions attached to the same event; remove duplicates |
| Scroll bars appear in parent picture | OS window smaller than designed picture size and Adapt Picture disabled | Enable Adapt Picture or increase the OS window |
| VBScript Left/Top assignment throws 'Object required' | Object not yet instantiated when SetTop is called | Use a 50 ms timer or HMIRuntime.ActiveScreen resolution to defer the assignment |
| Authorization always fails | User Administrator not synchronized with OS | Re-export user roles from SIMATIC Logon; re-download OS user administration |
| Position works on ES but not on OS client | Client uses cached faceplate; OS server config not propagated | Re-download to client with full package |
Best Practices
- Prefer per-instance default positions over global C edits; they survive APL library upgrades.
- Always keep the authorization block at the top of any OnClick action; it is mandatory for structured tags in PCS 7.
- Document any custom positioning in the project quality log so commissioning engineers can locate it.
- Avoid hard-coded coordinates when the OS targets multiple resolutions; pair SetLeft/SetTop with Adapt Picture for portability.
- Re-test every change on a 1080p panel and a 4K panel before signing off the OS download.
Related Standards and Documentation
For further verification of operator authorization levels and the WinCC scripting API, refer to the official Siemens documentation set:
- Siemens Industry Online Support
- SIMATIC PCS 7 OS Configuration Manual
- WinCC Scripting: C and VBS Reference
Which approach is least invasive in PCS 7 V9?
Set Use default position = No on the APL block icon instance and enter pixel coordinates. No scripts change, so APL upgrades cannot overwrite your settings.
What does SetLeft return and what should I do with it?
SetLeft returns BOOL: TRUE on success, FALSE if the picture or object name is invalid or the runtime is read-only. Capture the return value and log a diagnostic message on FALSE to identify silent failures.
Why does my VBScript position assignment fail at runtime?
The dialog object may not yet be instantiated when the assignment runs. Wrap the move in a 50 ms HMIRuntime.Timers callback or query HMIRuntime.ActiveScreen until the child picture is visible.
Can I set negative coordinates for SetLeft or SetTop?
Yes, the function accepts negative values. On a single monitor, negative values clip the dialog. On multi-monitor setups with extended desktop, negative coordinates route the dialog onto the secondary screen.
How do I prevent unauthorized changes when repositioning the dialog?
Keep the PCS7_CheckPermission(lpszTag, 5) block at the top of the OnClick action. It evaluates the user's operator area rights against the tag's authorization list and blocks the dialog from opening at all for unauthorized users.