Sub TDS_PicControl (CmdString, xPos, yPos)
'This function handles Screenswitching
'CmdString: Command to proceed - Code#PictureName
' Format Code#Picturename1#Picturename2#Picturename3
' Code: *
' !!+-- 1=switch of Footer
' !+--- 1=switch of Workspace
' +---- 1=switch of Header
' Note: for each x=1 a Picturename is required
' Example: 010#myName -> change workspace to Picture myName
' 110#myHeader#myWorkspace -> change Header and Workspace
' Code: 2
' Show Screen "WinMenue" with PictureName
'xPos.....: x-Position of Mouse
'yPos.....: y-position of Mouse
'
'v 05.02.11 TDS/M.Schill
Dim CmdField 'Substrings of CmdString
Dim xLeft 'Position Left of Menue Window
Dim xWidth 'width of screen
Dim xWidthObj 'width of Menue Window
'On Error Resume Next
CmdField = Split(CmdString, "#", -1, 1) 'Split Comand string
Select Case CmdField(0)
Case "100": 'Replace Header
HMIRuntime.Screens("WinWorkspace").ScreenItems("WinMenue").Visible = False
HMIRuntime.Tags("szPicHeader").Write CmdField(1)
Case "101": 'Replace Header and Footer
HMIRuntime.Screens("WinWorkspace").ScreenItems("WinMenue").Visible = False
HMIRuntime.Tags("szPicHeader").Write CmdField(1)
HMIRuntime.Tags("szPicFooter").Write CmdField(2)
Case "011": 'Replace Workspace and Footer
HMIRuntime.Screens("WinWorkspace").ScreenItems("WinMenue").Visible = False
HMIRuntime.Tags("szPicWorkspace").Write CmdField(1)
HMIRuntime.Tags("szPicFooter").Write CmdField(2)
Case "111": 'Replace Workspace and Header and Footer
HMIRuntime.Screens("WinWorkspace").ScreenItems("WinMenue").Visible = False
HMIRuntime.Tags("szPicHeader").Write CmdField(1)
HMIRuntime.Tags("szPicWorkspace").Write CmdField(2)
HMIRuntime.Tags("szPicFooter").Write CmdField(3)
Case "2": 'Shown Menue
HMIRuntime.Screens("WinWorkspace").ScreenItems("WinMenue").ScreenName = CmdField(1)
HMIRuntime.Screens("WinWorkspace").ScreenItems("WinMenue").Top = 0
xLeft = HMIRuntime.Screens("Start").ScreenItems("WinHeader").Left
xLeft = xLeft + HMIRuntime.Screens("WinHeader").ScreenItems(CmdString).Left
HMIRuntime.Screens("WinWorkspace").ScreenItems("WinMenue").Left = xLeft
HMIRuntime.Screens("WinWorkspace").ScreenItems("WinMenue").Visible = True
'check right border of screen
xWidth = HMIRuntime.Screens("Start").Width
xWidthObj = HMIRuntime.Screens("WinWorkspace").ScreenItems("WinMenue").Width
If (xLeft + xWidthObj) > xWidth Then
xLeft = xWidth - xWidthObj
HMIRuntime.Screens("WinWorkspace").ScreenItems("WinMenue").Left = xLeft
End If
Case Else
MsgBox "Comand string unknown" & CmdString
End Select
End Sub
问题补充:
本人学习了一段朋友给的WINCC程序,象“WinWorkspace”“WinMenue“在程序中没有此变量,象"szPicWorkspace"之类的有此变量,不知此段程序是什么意思?百思不得其解,请广大论坛中的同仁指教!象这样的语句:HMIRuntime.Screens("WinWorkspace").ScreenItems("WinMenue").Visible = False
HMIRuntime.Tags("szPicHeader").Write CmdField(1) 不知是什么意思,或者哪里有参考资料,谢谢您们了!!!
最佳答案
HMIRuntime.Screens("WinWorkspace").ScreenItems("WinMenue").Visible = False
运行系统中的名称为 "WinWorkspace"的画面中的 名字为"WinMenue"的对象的显示属性为否(即不显示)。
HMIRuntime.Tags("szPicHeader").Write CmdField(1)
运行系统中 名称为"szPicHeader"的变量中写(赋) CmdField(1) 的值。
参考资料:
《WinCC脚本应用》链接:
http://bbs.iianews.com/viewthread.php?tid=35837
《WinCC 脚本系统》下载:
http://bbs.shejis.com/thread-1734591-1-2.html
《 SIMATIC WinCC 全局脚本手册(中文)》下载:
http://www.gongkong.com/Common/Details.aspx?c=&m=&l=&Type=datum&CompanyID=&Id=C-AF12-8B5AAD9F9BF0
或http://www.chinakong.com/download/listdown.asp?id=346
创建脚本的技巧与窍门:
http://www.ad.siemens.com.cn/service/search/
C 和 VB 脚本演示项目:
http://www.ad.siemens.com.cn/service/search/?pno=3&qu=%E8%84%9A%E6%9C%AC&pa=dc
WinCC Scripting: VBS, ANSI-C, VBA:
http://support.automation.siemens.com/WW/view/en/37572697
提问者对于答案的评价:
谢谢!
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc267314.html