Is this IMPOSSIBLE to solve???

 

Can someone teach me how to solve it to me please?? it is "simple"

I created this code so you guys can test it.

I just want to know why my OnChartEvent() stops working when i drag the "Box".

if you guys check the buttons, you can notice that they stop doing their OnChartEvent() function.


int framex=(int)ObjectGet("Box",OBJPROP_XDISTANCE);
int framey=(int)ObjectGet("Box",OBJPROP_YDISTANCE);
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Panel(); 
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
ObjectDelete("BUTTON2");
ObjectDelete("BUTTON");
ObjectDelete("Box"); 
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  { }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
  if (CHARTEVENT_OBJECT_CLICK && sparam=="BUTTON")
  {
  ObjectSetInteger(0,"BUTTON2",OBJPROP_STATE,false);
  }
  
   if (CHARTEVENT_OBJECT_CLICK && sparam=="BUTTON2")
  {
  ObjectSetInteger(0,"BUTTON",OBJPROP_STATE,false);
  }

   TrackMove(); 
  }
//+------------------------------------------------------------------+

void Panel()
   {
   if (ObjectCreate(0,"Box",OBJ_RECTANGLE_LABEL,0,0,0))
     {
   ObjectSetInteger(0,"Box",OBJPROP_XDISTANCE,5); 
   ObjectSetInteger(0,"Box",OBJPROP_YDISTANCE,315); 
   ObjectSetInteger(0,"Box",OBJPROP_XSIZE,160); 
   ObjectSetInteger(0,"Box",OBJPROP_YSIZE,270); 
   ObjectSetInteger(0,"Box",OBJPROP_BGCOLOR,clrWhiteSmoke); 
   ObjectSetInteger(0,"Box",OBJPROP_BORDER_TYPE,BORDER_FLAT); 
   ObjectSetInteger(0,"Box",OBJPROP_CORNER,CORNER_LEFT_LOWER); 
   ObjectSetInteger(0,"Box",OBJPROP_COLOR,clrBlack); 
   ObjectSetInteger(0,"Box",OBJPROP_STYLE,STYLE_SOLID);  
   ObjectSetInteger(0,"Box",OBJPROP_BACK,false); 
   ObjectSetInteger(0,"Box",OBJPROP_SELECTABLE,true); 
   ObjectSetInteger(0,"Box",OBJPROP_SELECTED,false); 
   ObjectSetInteger(0,"Box",OBJPROP_HIDDEN,true); 
   ObjectSetInteger(0,"Box",OBJPROP_ZORDER,0);
      }
   
   if (ObjectCreate(0,"BUTTON",OBJ_BUTTON,0,0,0))
      {
   ObjectSetInteger(0,"BUTTON",OBJPROP_XDISTANCE,10); 
   ObjectSetInteger(0,"BUTTON",OBJPROP_YDISTANCE,215); 
   ObjectSetInteger(0,"BUTTON",OBJPROP_XSIZE,70); 
   ObjectSetInteger(0,"BUTTON",OBJPROP_YSIZE,70); 
   ObjectSetInteger(0,"BUTTON",OBJPROP_CORNER,CORNER_LEFT_LOWER); ////
   ObjectSetString(0,"BUTTON",OBJPROP_TEXT,"BUTTON"); 
   ObjectSetString(0,"BUTTON",OBJPROP_FONT,"Arial Bold");  
   ObjectSetInteger(0,"BUTTON",OBJPROP_FONTSIZE,10); 
   ObjectSetInteger(0,"BUTTON",OBJPROP_COLOR,clrBlack); 
   ObjectSetInteger(0,"BUTTON",OBJPROP_BGCOLOR,clrGray);  
   ObjectSetInteger(0,"BUTTON",OBJPROP_BORDER_COLOR,clrBlack);  
   ObjectSetInteger(0,"BUTTON",OBJPROP_BACK,false); //////////////////
   ObjectSetInteger(0,"BUTTON",OBJPROP_STATE,true); /////////////////
   ObjectSetInteger(0,"BUTTON",OBJPROP_SELECTABLE,false); ////////////
   ObjectSetInteger(0,"BUTTON",OBJPROP_SELECTED,false); //////////////
   ObjectSetInteger(0,"BUTTON",OBJPROP_HIDDEN,true); /////////////////
   ObjectSetInteger(0,"BUTTON",OBJPROP_ZORDER,0);/////////////////////
      }
   
   if (ObjectCreate(0,"BUTTON2",OBJ_BUTTON,0,0,0))
      {
   ObjectSetInteger(0,"BUTTON2",OBJPROP_XDISTANCE,90); 
   ObjectSetInteger(0,"BUTTON2",OBJPROP_YDISTANCE,215); 
   ObjectSetInteger(0,"BUTTON2",OBJPROP_XSIZE,70); 
   ObjectSetInteger(0,"BUTTON2",OBJPROP_YSIZE,70); 
   ObjectSetInteger(0,"BUTTON2",OBJPROP_CORNER,CORNER_LEFT_LOWER); ////
   ObjectSetString(0,"BUTTON2",OBJPROP_TEXT,"BUTTON2"); 
   ObjectSetString(0,"BUTTON2",OBJPROP_FONT,"Arial Bold");  
   ObjectSetInteger(0,"BUTTON2",OBJPROP_FONTSIZE,10); 
   ObjectSetInteger(0,"BUTTON2",OBJPROP_COLOR,clrBlack); 
   ObjectSetInteger(0,"BUTTON2",OBJPROP_BGCOLOR,clrGray);  
   ObjectSetInteger(0,"BUTTON2",OBJPROP_BORDER_COLOR,clrBlack);  
   ObjectSetInteger(0,"BUTTON2",OBJPROP_BACK,false); //////////////////
   ObjectSetInteger(0,"BUTTON2",OBJPROP_STATE,false); /////////////////
   ObjectSetInteger(0,"BUTTON2",OBJPROP_SELECTABLE,false); ////////////
   ObjectSetInteger(0,"BUTTON2",OBJPROP_SELECTED,false); //////////////
   ObjectSetInteger(0,"BUTTON2",OBJPROP_HIDDEN,true); /////////////////
   ObjectSetInteger(0,"BUTTON2",OBJPROP_ZORDER,0);/////////////////////
      }
   }

 void TrackMove()
 {
     while(ObjectGetInteger(0,"Box",OBJPROP_SELECTED))
    {
      if(framex!=(int)ObjectGet("Box",OBJPROP_XDISTANCE) || framey!=(int)ObjectGet("Box",OBJPROP_YDISTANCE))
      { 
         framex=(int)ObjectGet("Box",OBJPROP_XDISTANCE);
         framey=(int)ObjectGet("Box",OBJPROP_YDISTANCE);
         
         ObjectSet("BUTTON",OBJPROP_XDISTANCE,5+framex); 
         ObjectSet("BUTTON",OBJPROP_YDISTANCE,-100+framey);
         
         ObjectSet("BUTTON2",OBJPROP_XDISTANCE,85+framex); 
         ObjectSet("BUTTON2",OBJPROP_YDISTANCE,-100+framey);
      }
     Sleep(0);
    }
 }    
Files:
Box.mq4  12 kb
 
Deanda_Amaral: I just want to know why my OnChartEvent() stops working when i drag the "Box".

Your OnChartEvent calls TrackMove which never returns.

My GUI EA (for MT4) just waits for the box move to complete (CHARTEVENT_OBJECT_DRAG) and then moves the rest of the GUI
          Indicators: 'Money Manager Graphic Tool' indicator by 'takycard' Forum - Page 6

 
whroeder1:

Your OnChartEvent calls TrackMove which never returns.

My GUI EA (for MT4) just waits for the box move to complete (CHARTEVENT_OBJECT_DRAG) and then moves the rest of the GUI
          Indicators: 'Money Manager Graphic Tool' indicator by 'takycard' Forum - Page 6

I tried to reverse engineer your GUI to apply this that you've  told me on my EA... but i failed miserably.

I'm sorry if I sound ignorant, but i didn't figure out how to do it that you told me to make the TrackMove returns.

I'm a begginer in MQL coding and I'm struggling trying to do it, could you please code it for me (the return code) if it is not to ask too much? Or maybe give me another hint on how to do it...

 
I have no trackmove in the code. What part of
   else  if(id == CHARTEVENT_OBJECT_DRAG){
      if(      sparam == "MMGT_RecMov"){
         orgX  = (int) ObjectGet("MMGT_RecMov", OBJPROP_XDISTANCE);
         orgY  = (int) ObjectGet("MMGT_RecMov", OBJPROP_YDISTANCE);
         create_gui();
      }
is unclear. If the selected rectangle is moved, redraw the GUI at the new location.
 

whroeder1:
I have no trackmove in the code. What part of is unclear. If the selected rectangle is moved, redraw the GUI at the new location.

Yeah i get it, your EA does it great, but is it possible to move everything together at the same time and not just later?? Just like the Box does?

I feel like my code is so close to doing it right, but I don't know what is wrong and what can I do to Return TrackMove...

 
Deanda_Amaral: but is it possible to move everything together at the same time and not just later?? Just like the Box does?

Box doesn't per your post. There is no mouse down event only click and drag. So you can't see the drag in progress.

I was thinking, click select the object, follow the mouse until unselect. But click, move, click is not mouse down, drag, release.

 
int OnInit()
  {
   ChartSetInteger(0,CHART_EVENT_MOUSE_MOVE,true);
   Panel(); 
   return(INIT_SUCCEEDED);
  } 

void TrackMove()
 {
      if(framex!=(int)ObjectGet("Box",OBJPROP_XDISTANCE) || framey!=(int)ObjectGet("Box",OBJPROP_YDISTANCE))
      { 
         framex=(int)ObjectGet("Box",OBJPROP_XDISTANCE);
         framey=(int)ObjectGet("Box",OBJPROP_YDISTANCE);
         
         ObjectSet("BUTTON",OBJPROP_XDISTANCE,5+framex); 
         ObjectSet("BUTTON",OBJPROP_YDISTANCE,-100+framey);
         
         ObjectSet("BUTTON2",OBJPROP_XDISTANCE,85+framex); 
         ObjectSet("BUTTON2",OBJPROP_YDISTANCE,-100+framey);
         
         ChartRedraw();
      }
 }  

Treat yourself.