QQ登录

只需一步,快速开始

在 WinCC 中,如何在运行系统中通过脚本来改变对象颜色(背景、边框、文本

[ 复制链接 ]
在 WinCC 中,如何在运行系统中通过脚本来改变对象颜色(背景、边框、文本

描述
从 WinCC 7.0 开始, 包含 32 位值的颜色,并支持颜色透明度。

可以在运行系统中通过脚本改变颜色和对象元素的透明度。
颜色相关的对象元素包括背景颜色、文本颜色和边框颜色。
(诸如位置和尺寸等其它可以在运行系统中改变的对象属性,可以使用同样的方式进行组态。)


在 WinCC 中,如何在运行系统中通过脚本来改变对象颜色(背景、边框、文本

在 WinCC 中,如何在运行系统中通过脚本来改变对象颜色(背景、边框、文本



  1. <font size="2">
  2. -------------------- C-Script 1a --------------------

  3. long GetPaletteColor(int ColorIndex)
  4. {
  5.   if (ColorIndex > 199)
  6.   ColorIndex = 199;
  7.   return pow(2,31) + ColorIndex;
  8. }




  9. -------------------- C-Script 1b --------------------

  10. SetBackColor(lpszPictureName, "Testobjekt", GetPaletteColor(4));



  11. -------------------- C-Script 2a --------------------

  12. long CreateRGBColor32(int nRed, int nGreen, int nBlue, ...)
  13. {
  14.   va_list argptr;
  15.   int Alpha;
  16.   long Color;
  17.   va_start (argptr, nBlue);
  18.   
  19.   if (argptr != NULL)
  20.     Alpha = va_arg(argptr, int);
  21.   else

  22.   Alpha = 0;
  23.   va_end(argptr);

  24.   Color = nRed + (pow(2, 8)) * nGreen + (pow(2, 16)) * nBlue + (pow(2, 24)) * (Alpha + 1);
  25.   return Color;
  26. }



  27. -------------------- C-Script 2b --------------------

  28. SetBackColor(lpszPictureName, "Testobjekt", CreateRGBColor32(255, 60, 100, 30));



  29. -------------------- VB-Script 1 --------------------

  30. Dim ColorIndex
  31. ColorIndex=5
  32. ScreenItems("Button5").BackColor = ((-2147483648)+ColorIndex)



  33. -------------------- VB-Script 2 --------------------

  34. ScreenItems(揟estobject?.BackColor=RGB(70,60,100)
  35. ScreenItems(揟estobject?.Transparency=50
  36. </font>
复制代码



回复

使用道具 举报

点击查看
快速回复 返回列表 客服中心 搜索