ResourceCreate()函数用法解疑讨论
ResourceCreateCreates an image resource based on a data set. There are two variants of the function:Creating a resource based on a file
boolResourceCreate(
const string resource_name, // Resource name
const string path // A relative path to the file
);
Creating a resource based on the array of pixels
boolResourceCreate(
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
);
大家都知道这两个函数,不知大家伙在用的时候是否遇到了一些问题呢?
我这里就跟大家说一下我用的过程中的具体实用问题,可能我的调用不合规范:
用第一种形式调用时,无论怎么修改,就是创建不了,所以第二种压根不能用。总是提示文件名称错误。
至于正确的形式应该怎么写呢?我们一起来讨论一下吧,
我试过了所有的字符串组合,但是仍然不可行
//+------------------------------------------------------------------+
//| 自定义描绘图像.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();
} {:1_181:} {:1_179:} 顶下 {:1_180:}
页:
[1]