5评论

0收藏

ResourceCreate()函数用法解疑讨论

avatar gscyhxaywn | 2334 人阅读 | 5 人评论 | 2017-09-17

ResourceCreate
Creates an image resource based on a data set. There are two variants of the function:
Creating a resource based on a file
bool  ResourceCreate(
   const string      resource_name,       // Resource name
   const string      path                 // A relative path to the file
   );

Creating a resource based on the array of pixels
bool  ResourceCreate(
   const string      resource_name,       // Resource name
   const uint&       data[],              // Data set as an array
   uint              img_width,           // The width of the image resource
   uint              img_height,          // The height of the image resource
   uint              data_xoffset,        // The horizontal rightward offset of the upper left corner of the image
   uint              data_yoffset,        // The vertical downward offset of the upper left corner of the image
   uint              data_width,          // The total width of the image based on the data set
   ENUM_COLOR_FORMAT color_format         // Color processing method
   );


大家都知道这两个函数,不知大家伙在用的时候是否遇到了一些问题呢?
我这里就跟大家说一下我用的过程中的具体实用问题,可能我的调用不合规范:
用第一种形式调用时,无论怎么修改,就是创建不了,所以第二种压根不能用。总是提示文件名称错误。
至于正确的形式应该怎么写呢?我们一起来讨论一下吧,

""
还没有人打赏,支持一下

评论|共 5 个

gscyhxaywn

发表于 2017-9-17 21:36:59 | 显示全部楼层

我试过了所有的字符串组合,但是仍然不可行
//+------------------------------------------------------------------+
//|                                                      自定义描绘图像.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#resource "\\Files\\safe.bmp"

#include <xhinc_errordescription_event.mqh>
#include <Object_Myself\xxinc_obj_bitmap_label.mqh>
string file1_path = "\\Files\\safe.bmp";
string source_name = "::sf.bmp";
/*
string file_on_path = "\\Images\\zhifubao.bmp";
string file_off_path = "\\Images\\zhifubao.bmp";
*/
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(1);
   
   if(ResourceCreate("sss2","\\Files\\zhifubao.bmp")==true){
      PrintFormat("%s 数据源已创建完成",file1_path);
   }
   else{
      ErrorEvent();
   }
   
   if(ResourceFree("::Files\\safe.bmp")==true){
      PrintFormat("释放资源成功");
   }
   else{
      PrintFormat("释放资源失败");
      ErrorEvent();
   }

uqhdifhe

发表于 2020-11-13 16:35:45 | 显示全部楼层

lscyf

发表于 2021-7-6 14:32:30 | 显示全部楼层

小云

发表于 2021-7-19 10:00:21 | 显示全部楼层

顶下

徐文荣

发表于 2023-9-29 14:10:50 | 显示全部楼层

您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则