MQL5Book/Scripts/p5/ObjectBitmapOffset.mq5
super.admin 1c8e83ce31 convert
2025-05-30 16:09:41 +02:00

47 lines
2.1 KiB
MQL5

//+------------------------------------------------------------------+
//| ObjectBitmapOffset.mq5 |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com |
//| |
//| The script creates a bitmap label. |
//+------------------------------------------------------------------+
#include "ObjectPrefix.mqh"
//+------------------------------------------------------------------+
//| Create and setup a single bitmap label |
//+------------------------------------------------------------------+
void SetupBitmap(const int i, const int x, const int y, const int size,
const string imageOn, const string imageOff = NULL)
{
// create an object
const string name = ObjNamePrefix + "Tool-" + (string)i;
ObjectCreate(0, name, OBJ_BITMAP_LABEL, 0, 0, 0);
ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_RIGHT_UPPER);
// position
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x);
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y);
ObjectSetInteger(0, name, OBJPROP_XSIZE, size);
ObjectSetInteger(0, name, OBJPROP_YSIZE, size);
ObjectSetInteger(0, name, OBJPROP_XOFFSET, i * size);
ObjectSetInteger(0, name, OBJPROP_YOFFSET, 0);
// image
ObjectSetString(0, name, OBJPROP_BMPFILE, imageOn);
// ObjectSetString(0, name, OBJPROP_BMPFILE, 1, imageOff);
}
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
const int icon = 46;
for(int i = 0; i < 7; ++i)
{
SetupBitmap(i, 10, 10 + i * icon, icon,
"\\Files\\MQL5Book\\icons-322-46.bmp");
}
}
//+------------------------------------------------------------------+