//+-------------------+
//| zTestWinRect.mq4 |
//+-------------------+
#property copyright "z"
#property link      ""
#import "user32.dll"
int GetWindowDC(int hWnd); 
int GetClientRect(int hWnd, int rect[4]); 
int ReleaseDC(int hWnd, int hDC); 
#import
#import "gdi32.dll"
int GetPixel(int hDC, int XPos, int YPos); 
#import
//Type RECT   // structure
//  Left As Long
//  Top As Long
//  Right As Long
//  Bottom As Long
//End Type
int init()   {return(0);}
int deinit() {return(0);}
int start()
{
   int iRelRslt = 0;
   int r[4];
   int iLeft, iTop, iRight, iBottom;
   string sMsg = "x";
   int hWnd = WindowHandle(Symbol(),Period());
   sMsg = "win hndl is: " + hWnd;
   Print(sMsg);
   GetClientRect(hWnd, r);
   iLeft = r[0];
   iTop = r[1];
   iRight = r[2];
   iBottom = r[3];
   sMsg = "result r: " +  r[0] + "  " + r[1] + "  " + r[2] + "  " + r[3];
   Print(sMsg);
   sMsg = "result i: " +  iLeft + "  " + iTop + "  " + iRight + "  " + iBottom;
   Print(sMsg);
   int hDCWnd = GetWindowDC(hWnd);
   sMsg = "DC hndl is: " + hDCWnd;
   Print(sMsg);
   int iXLoop = 0;
   int iYLoop = 0;
   int iPixelNext = 0;
   sMsg = "starting loops";
   Print(sMsg);
   for(iYLoop=iBottom-3;iYLoop>10;iYLoop--)
   {
      for(iXLoop=1;iXLoop<200;iXLoop++)
      {
         iPixelNext = GetPixel(hDCWnd,iXLoop,iYLoop);
         if(iPixelNext == 65535)   //yellow
         {
            sMsg = "found yellow at x: " + iXLoop + ", y: " + iYLoop;
            Print(sMsg);
            break;
         }
      }
   }      
   sMsg = "end loops";
   Print(sMsg);
   iRelRslt = ReleaseDC(hWnd, hDCWnd); 
   return(0);
}







