MaximizeRestoreWindow

Author: Copyright 2014, GoldenMoney
0 Views
0 Downloads
0 Favorites
MaximizeRestoreWindow
//+------------------------------------------------------------------+
//|                                                          max.mq4 |
//|                                      Copyright 2014, GoldenMoney |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, GoldenMoney"
#property link      "http://www.mql5.com"
#property version   "1.00"
#property strict

#import "user32.dll"
int GetParent(int hWnd);
int SendMessageW(int hWnd,int Msg,int wParam,int lParam);
bool IsZoomed(int hWnd);
#import

#define WM_MDIMAXIMIZE 0x0225
#define WM_MDIRESTORE  0x0223
//+------------------------------------------------------------------+
//| Maximize Window                                                  |
//+------------------------------------------------------------------+
int WindowMaximize(int hwnd)
  {
   int Parent=GetParent(hwnd);
   return SendMessageW(GetParent(Parent), WM_MDIMAXIMIZE, Parent, 0);
  }
//+------------------------------------------------------------------+
//| Restore Window size                                              |
//+------------------------------------------------------------------+
int WindowRestore(int hwnd)
  {
   int Parent=GetParent(hwnd);
   return SendMessageW(GetParent(Parent), WM_MDIRESTORE, Parent, 0);
  }
//+------------------------------------------------------------------+
//| Get Window handle                                                |
//+------------------------------------------------------------------+
int WindowGetHwnd()
  {
   return WindowHandle(Symbol(),Period());
  }
//+------------------------------------------------------------------+
//| Check Window is maximized                                        |
//+------------------------------------------------------------------+  
bool IsWondowZoomed(int hWnd)
  {
   int Parent=GetParent(hWnd);
   int Result=IsZoomed(Parent);
   if(Result!=0)
      return(True);
   return(False);
  }
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   int hWnd=WindowGetHwnd();
   if(IsWondowZoomed(hWnd))
      WindowRestore(hWnd);
   else
      WindowMaximize(hWnd);
  }
//+------------------------------------------------------------------+

Comments