109 Zeilen
5,4 KiB
MQL5
109 Zeilen
5,4 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| iTestResize.mq5 |
|
|
//| Copyright 2025, MetaQuotes Ltd. |
|
|
//| https://www.mql5.com |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2025, MetaQuotes Ltd."
|
|
#property link "https://www.mql5.com"
|
|
#property version "1.00"
|
|
#property indicator_separate_window
|
|
#property indicator_buffers 0
|
|
#property indicator_plots 0
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Включаемые библиотеки |
|
|
//+------------------------------------------------------------------+
|
|
#include "Controls\Controls.mqh" // Библиотека элементов управления
|
|
|
|
CContainer *container=NULL; // Указатель на графический элемент Container
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Custom indicator initialization function |
|
|
//+------------------------------------------------------------------+
|
|
int OnInit()
|
|
{
|
|
//--- Ищем подокно графика
|
|
int wnd=ChartWindowFind();
|
|
|
|
//--- Создаём графический элемент "Контейнер"
|
|
container=new CContainer("Container","",0,wnd,100,40,300,200);
|
|
if(container==NULL)
|
|
return INIT_FAILED;
|
|
|
|
//--- Устанавливаем параметры контейнера
|
|
container.SetID(1); // Идентификатор
|
|
container.SetAsMain(); // На графике обязательно должен быть один главный элемент
|
|
container.SetBorderWidth(1); // Ширина рамки (отступ видимой области на один пиксель с каждой стороны контейнера)
|
|
container.SetResizable(true); // Возможность менять размеры перетаскиванием за грани и углы
|
|
container.SetName("Main container"); // Наименование
|
|
|
|
//--- Присоединяем к контейнеру элемент GroupBox
|
|
CGroupBox *groupbox=container.InsertNewElement(ELEMENT_TYPE_GROUPBOX,"","Attached Groupbox",4,4,container.Width()*2+20,container.Height()*3+10);
|
|
if(groupbox==NULL)
|
|
return INIT_FAILED;
|
|
groupbox.SetGroup(1); // Номер группы
|
|
|
|
//--- В цикле создаёи и присоединяем к элементу GroupBox 30 строк из элементов "Текстовая метка"
|
|
for(int i=0;i<30;i++)
|
|
{
|
|
string text=StringFormat("This is test line number %d to demonstrate how scrollbars work when scrolling the contents of the container.",(i+1));
|
|
int len=groupbox.GetForeground().TextWidth(text);
|
|
CLabel *lbl=groupbox.InsertNewElement(ELEMENT_TYPE_LABEL,text,"TextString"+string(i+1),8,8+(20*i),len,20);
|
|
if(lbl==NULL)
|
|
return INIT_FAILED;
|
|
}
|
|
//--- Отрисовываем на графике все созданные элементы и распечатываем их описание в журнале
|
|
container.Draw(true);
|
|
container.Print();
|
|
|
|
//--- Успешно
|
|
return(INIT_SUCCEEDED);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Custom deindicator initialization function |
|
|
//+------------------------------------------------------------------+
|
|
void OnDeinit(const int reason)
|
|
{
|
|
//--- Удаляем элемент Контейнер и уничтожаем менеджер общих ресурсов библиотеки
|
|
delete container;
|
|
CCommonManager::DestroyInstance();
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Custom indicator iteration function |
|
|
//+------------------------------------------------------------------+
|
|
int OnCalculate(const int rates_total,
|
|
const int prev_calculated,
|
|
const datetime &time[],
|
|
const double &open[],
|
|
const double &high[],
|
|
const double &low[],
|
|
const double &close[],
|
|
const long &tick_volume[],
|
|
const long &volume[],
|
|
const int &spread[])
|
|
{
|
|
//---
|
|
|
|
//--- return value of prev_calculated for next call
|
|
return(rates_total);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| ChartEvent function |
|
|
//+------------------------------------------------------------------+
|
|
void OnChartEvent(const int id,
|
|
const long &lparam,
|
|
const double &dparam,
|
|
const string &sparam)
|
|
{
|
|
//--- Вызываем обработчик OnChartEvent элемента Контейнер
|
|
container.OnChartEvent(id,lparam,dparam,sparam);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Таймер |
|
|
//+------------------------------------------------------------------+
|
|
void OnTimer(void)
|
|
{
|
|
//--- Вызываем обработчик OnTimer элемента Контейнер
|
|
container.OnTimer();
|
|
}
|
|
//+------------------------------------------------------------------+
|