Download MetaTrader 5
To add comments, please log in or register
Have you found an error in our products? Apply to Service Desk!
Gatesby
41
Gatesby 2016.10.04 05:13 

Hi, Gurus:

I stuck in an issue as topic and I need someone give me hints or examples ! Thanks!

I want click a button and control the visual status of a object such as rectangle label which displays some info about MT4 account in my EA.

Due to the source code file totally  has 965 lines and post this article got a rejection from the MQL4 forum. So I attached the mq4 file as below: 

Files:
aaa_1.mq4 84 kb
whroeder1
13596
whroeder1 2016.10.04 14:57  

I rewrote takycard's GUI because it wasn't working. He changed the Visibility of Objects I simply delete or create the object. Indicators: 'Money Manager Graphic Tool' indicator by 'takycard' Forum - Page 5

Gatesby
41
Gatesby 2016.10.05 01:18  

Why did I run the order_graphic_tool_WHRoeder.mq4 on my MT4 terminal but nothing can be see at all, just EA smile face & EA name displays on the RIGHT_UPPER_CORNER of a chart ?

Or is this EA just a hint of sample for my puzzle ?  My MT4 terminal is Version 4.00 build 1010 Aug.18, 2016 updated! 

It seems that the sample you offered is just discussed in MQL5 forum. 

 

Thanks for your reply! Good luck!

whroeder1
13596
whroeder1 2016.10.05 11:28  
Gatesby: Why did I run the order_graphic_tool_WHRoeder.mq4 on my MT4 terminal but nothing can be see at all, just EA smile face & EA name displays on the RIGHT_UPPER_CORNER of a chart ?
If you had bothered to read the original post, you would know that pressing "b" or "s" brings up the GUI.
Gatesby
41
Gatesby 2016.10.08 07:35  

Thanks!

After read your source code I found my solution! Just call ObjectDelete() function in  OnChartEvent() !

//Global variants
bool     Set_Hide = true;        // The Account Info Display Status

#include <stdlib.mqh>
#include <WinUser32.mqh> 
int OnInit()
{
   ...

}

void OnDeinit(const int reason)
{
   ...
}

void OnChartEvent(const int id,
         const long &lparam,
         const double &dparam,
         const string &sparam)
{
  if(sparam == "Show")
  {
    ObjectSetInteger(0,"Show",OBJPROP_STATE,false);

    if(Set_Hide)
     {
       if(AccountInfo())
       {
         //ObjectSetInteger(0,"Statistics",OBJPROP_HIDDEN,false);
         Set_Hide = false;
         Comment( "显示账户统计窗口!");
       }
    }
    else
    {
      ObjectDelete(0,"Statistics");
      Set_Hide = true;
      Comment( "隐藏账户统计窗口!");
   }
}
//+------------------------------------------------------------------+
//| Account Statistics function                   |
//+------------------------------------------------------------------+
bool AccountInfo()
{  
   if(Set_Hide)
   {
      //ObjectCreate("FrameLabel",OBJ_RECTANGLE_LABEL,0,0,0,0,0,0); 
      if(!RectLabelCreate(0,"Statistics",0,xRec,yRec,xRec_size,yRec_size,clrPowderBlue,BORDER_FLAT,CORNER_LEFT_UPPER,
            clrWhite,STYLE_SOLID,1,false,false,false,1))
       {
           string Err=GetLastError();
           Print("Error creating Rectangle Label. Error code ",Err,". ",ErrorDescription(Err));
       } 
       Set_Hide = false;     
}
Gatesby
41
Gatesby 2016.10.09 08:27  

Updated version for subtle adjustment!



 //Global variants 
int      newxPos;
int      newyPos;

void OnChartEvent(const int id,
         const long &lparam,
         const double &dparam,
         const string &sparam)
{
   if(sparam == "Show")
   {           
     if(Set_Hide)
     {
        if(!ObjectGetInteger(0,"Move",OBJPROP_STATE)) // What if GUI moved which position different from onInit() status and fixed at some place now click "show" button!
       {
          xRec = newxPos-Diff_X_RecLabel;   // X coordinate of Statistics
          yRec = newyPos-Diff_Y_Butt1;      // Y coordinate of Statistics
         if(AccountInfo())
         {
            Set_Hide = false;
            Comment( "显示账户统计窗口!");
          }                  
       }
       else
       {
          if(AccountInfo())
          {
            Set_Hide = false;
            Comment( "显示账户统计窗口!");
          }              
       }
     }
     else
     {
        ObjectDelete(0,"Statistics");
        Set_Hide = true;
        Comment( "隐藏账户统计窗口!");
     }
  }
}



/
To add comments, please log in or register