stange errors of standard function (WindowHandle()) and -values ERR_FILE_READ_ERROR => not defined ???

Back to topics list To post a new topic, please log in or register
avatar
2017
gooly 2015.08.16 10:52
 

Hi,

as I (Win7, 64, Term. 840, Editor 1154) wanted to compile  some of my old mqh I get some new previously not known Errors:

=> 'WindowHandle' - function not defined    Win32FuncsAll.mqh    846    27

This is the function:

void EnableOrdersHistoryAll(){
   int main = GetAncestor(WindowHandle(_Symbol, _Period), GA_ROOT);
   PostMessageW(main, WM_COMMAND, 33058, 0);
   Sleep(5000);
}

BUT WindoweHandle(..) should be a valid mql4-function (from the Reference):

WindowHandle

Returns the system handle of the chart window.

int  WindowHandle(
   string       symbol,     // symbol
   int          timeframe   // timeframe
   );

Parameters
symbol     [in]  Symbol.
timeframe  [in]  Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.
Returned value  Returns the system handle of the chart window. If the chart of symbol and timeframe has not been opened by the moment of function calling, 0 will be returned.

Example:
  int win_handle=WindowHandle("USDX",PERIOD_H1);
  if(win_handle!=0)
    Print("Window with USDX,H1 detected. Rates array will be copied immediately.");

And the editor does NOT highlight the function as a genuine mql4-function.

?????


Beside that I get some more of those compiler errors:

'ERR_FILE_INVALID_HANDLE' - undeclared identifier    Win32FuncsAll.mqh    893    17

'ERR_FILE_READ_ERROR' - undeclared identifier    Win32FuncsAll.mqh    908    17

And even here these are mq4 predefined Error-code:

5007  ERR_FILE_INVALID_HANDLE  Invalid file handle (file closed or was not opened)
5015  ERR_FILE_READ_ERROR   File read error
 

Anybody else with errors like this?



BTW which one is correct - or better?

#include <file_name>
#include "file_name"

If I use in an mqh-file the <>-version and try to compile it I get:

can't open "C:\Users\..\MQL5\include\Win32FuncsAll.mqh" include file    Defines.mqh     13      11

But the \MQL5\.. does not exists - of course I am using MQL4,

but this

#include "file_name"

works it seems to to pretend to request MQL5.


PS: It would be so easy to check the path of the mqh-file to be compiled and to use for compilation the mq4-version in case one detects \MQL4\ and the mq5-version otherwise !!


avatar
12983
WHRoeder 2015.08.16 20:21 #
 

gooly:

BUT WindoweHandle(..) should be a valid mql4-function (from the Reference):

And the editor does NOT highlight the function as a genuine mql4-function.

BTW which one is correct - or better?

#include <file_name>
#include "file_name"
  1. They are both corrent and neither is better. The <angle> version means the file must be in the MQL4/includes directory, the "quote" version means the file is in the same directory as the includer. This is what Including Files (#include) - MQL4 Documentation says.
  2. My code compiles and works. When both your code and mine was written, there was no MQL4 WindowHandle. Thus the WinUser32 was required.
    #include <WinUser32.mqh>
    #import "user32.dll"
       int      GetAncestor(int, int);
    #import
    void     PauseTest(){
       datetime now = TimeCurrent();    static datetime oncePerTick;
       if(oncePerTick != now)if( IsTesting() )if( IsVisualMode() )if(
          IsDllsAllowed() ){   oncePerTick = now;               #define GA_ROOT 2
          for(int i=0; i<200000; i++){     // Delay required for speed=32 (max)
             if(IsStopped())   break;      // https://forum.mql4.com/32837 WH-DL
             int      main = GetAncestor(WindowHandle(_Symbol, _Period), GA_ROOT);
             if(i==0) PostMessageA(main, WM_COMMAND, 0x57a, 0); // 1402. Pause
          // TBD replace loop/postmessage with sendmessage
       }  }
       //{The PostMessage above sends the command to the main terminal. Thus it
       // only affects the active chart window. To maximize a window for example
       // must activate it first. https://forum.mql4.com/35336#538848
       //}See also SetForgroundWindow(h) https://www.mql5.com/en/code/mt4
    }
    

  3. PrintFormat("ih=%i, re=%i", ERR_FILE_INVALID_HANDLE, ERR_FILE_READ_ERROR);
    // 2015.08.16 14:25:22.282      testscr EURUSD,H1: ih=5007, re=5015
    
    Compiles fine for me.
Back to topics list  

To add comments, please log in or register