Я нашел очень полезный «индикатор» для МТ4, который позволяет развернуть/свернуть любой график двойным/тройным щелчком по нему.
Я безуспешно пытался портировать его на МТ5.
Я не уверен, что я делаю неправильно с Windows API. Я изменил типы на ulong/uint согласно MSDN. Я также использую CHART_WINDOW_HANDLE, чтобы получить файл hwnd.
Счетчик щелчков мышью, кажется, работает, но мне никогда не удавалось развернуть или свернуть окно диаграммы с помощью приведенного ниже кода.
Любая помощь будет принята с благодарностью.
//+------------------------------------------------------------------+
//| ClickMax.mq5 |
//| Copyright © 2020 | 2016, MaryJane |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2020 | 2016, MaryJane"
#property link "https://www.mql5.com"
#property version "1.00"
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots 0
#property strict
input uint clickDelay = 300;
input bool tripleClick = true;
#define SW_MAXIMIZE 3
#define SW_RESTORE 9
//+------------------------------------------------------------------------------------------------------------------------------------------------------+
// --- DLLs
#import "user32.dll"
ulong GetParent(ulong hWnd);
ulong GetWindow(ulong hWnd, uint uCmd);
bool ShowWindow(ulong hWnd, int nCmdShow);
bool IsZoomed(ulong hWnd);
#import
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
if(!TerminalInfoInteger(TERMINAL_DLLS_ALLOWED))
{
Alert("You have to allow DLLs for ClickMax to work");
return(INIT_FAILED);
}
else
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double &price[])
{
return(0);
}
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
static uint clicktime = GetTickCount();
static int clickcount = 0;
bool doubleclick = false;
if(_IsX64)
{
ulong hwnd = GetParent(CHART_WINDOW_HANDLE);
//ulong hwnd = CHART_WINDOW_HANDLE;
if(id == CHARTEVENT_CLICK)
{
uint test = GetTickCount() - clicktime;
if(GetTickCount() - clicktime < clickDelay)
clickcount++;
else
clickcount = 0;
if((tripleClick && clickcount==2) ||
(!tripleClick && clickcount==1))
doubleclick = true;
clicktime = GetTickCount();
if(doubleclick)
{
if(!IsZoomed(hwnd))
ShowWindow(hwnd, SW_MAXIMIZE);
else
ShowWindow(hwnd, SW_RESTORE);
clickcount = 0;
}
}
}
}
CHART_WINDOW_HANDLE
не звучит как реальный дескриптор окнаHWND
, чего ожидаетGetParent
. - person dxiv   schedule 26.10.2020hwnd
правильным дескриптором окна или нет? - person Rita Han   schedule 26.10.2020