//+--------------------------------------------------------------------------------+
//|                                                                   ClickMax.mq4 |
//+--------------------------------------------------------------------------------+
#property copyright "Copyright (c) 2016, MaryJane"
#property strict
#property indicator_chart_window
#define SW_MAXIMIZE     3
#define SW_RESTORE      9
#include <Winuser32.mqh>
#import "user32.dll"
#import

//+--------------------------------------------------------------------------------+
void OnDeinit(const int Reason) {}
//+--------------------------------------------------------------------------------+

int OnInit()
{
	if(!IsDllsAllowed())
   	{
   	   Alert("You have to allow DLLs for ClickMax to work");
   	   return INIT_FAILED; 
   	}
	else return INIT_SUCCEEDED;
}

//+--------------------------------------------------------------------------------+
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 &tickVolume[],const long &volume[],const int &spread[]) {return(rates_total);}
//+--------------------------------------------------------------------------------+

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
{
   bool doubleclick = false;
   static uint clicktime = GetTickCount();
   int hwnd = GetParent(WindowHandle(_Symbol, _Period));
   
   if(id == CHARTEVENT_CLICK)
      {
         if(GetTickCount() - clicktime < 300) doubleclick = true;
         clicktime = GetTickCount();
         if(doubleclick) {if(!IsZoomed(hwnd)) ShowWindow(hwnd,SW_MAXIMIZE); else ShowWindow(hwnd,SW_RESTORE);}
      }
}

//+--------------------------------------------------------------------------------+
