屏幕定位显示标签模块

楼主  收藏   举报   帖子创建时间:  2019-05-05 14:59 回复:0 关注量:926
基于程序运行中需要在不同位置显示文字的需求,我编制了一个名为 iDisplayInfo()的标准模块,准确输入参数就可以随意地、快速地显示信息了。下面是一个包含了该标准模块的程序调用范例。


QQ截图20161109173048.jpg

  1. #property copyright "Copyright 2012, laoyee"
  2. #property link "http://www.docin.com"
  3. //新价格到达时运行一次
  4. int start()
  5. {
  6. iDisplayInfo("Author", "作者:老易 QQ:9217XX", 1, 18, 15, 8, "", SlateGray);
  7. iDisplayInfo("Symbol", Symbol(), 1, 25, 30, 14, "Arial Bold", DodgerBlue);
  8. iDisplayInfo("TradeInfo", "欢迎使用!", 1, 5, 50, 9, "", Olive);
  9. //显示买入组信息
  10. iDisplayInfo(Symbol()+"-BuyGroup", "买入组", 1, 70, 70, 12, "Arial", Red);
  11. iDisplayInfo(Symbol()+"-Ask", DoubleToStr(Ask, Digits), 1, 70, 90, 12, "Arial", Red);
  12. //显示卖出组信息
  13. iDisplayInfo(Symbol()+"-SellGroup", "卖出组", 1, 5, 70, 12, "Arial", Green);
  14. iDisplayInfo(Symbol()+"-Bid", DoubleToStr(Bid, Digits), 1, 5, 90, 12, "Arial", Green);
  15. return(0);
  16. }
  17. //程序加载时运行一次
  18. int init()
  19. {
  20. return(0);
  21. }
  22. //程序卸载时运行一次
  23. int deinit()
  24. {
  25. return(0);
  26. }

  27. void iDisplayInfo(string LableName,string LableDoc,int Corner,int LableX,int LableY,int DocSize,string DocStyle,color DocColor)
  28. {
  29. if (Corner == -1) return(0);
  30. ObjectCreate(LableName, OBJ_LABEL, 0, 0, 0); //建立标签对象
  31. ObjectSetText(LableName, LableDoc, DocSize, DocStyle,DocColor); //定义对象属性
  32. ObjectSet(LableName, OBJPROP_CORNER, Corner); //确定坐标原点,0-左上角,1-右上角,2-左下角,3-右下角,-1-不显示
  33. ObjectSet(LableName, OBJPROP_XDISTANCE, LableX); //定义横坐标,单位像素
  34. ObjectSet(LableName, OBJPROP_YDISTANCE, LableY); //定义纵坐标,单位像素
  35. }
打赏