Download MetaTrader 5

how to create button minimize ??

To add comments, please log in or register
forextime8
399
forextime8  

i just created an easy 3 button,

1, button close buy

2, button close sell

3, and the new button, button minimize


on the pic, the top right button is button minimize,

when click it, the button close buy / sell,  i want it to minimize,

and click the 2nd time, it will show it again.


so what the function should i use for button minimize ?

should i use objectdelete function for this button ?

thanks for the help.



forextime8
399
forextime8  
//+------------------------------------------------------------------+ 
//| Delete the button                                                | 
//+------------------------------------------------------------------+ 
bool ButtonDelete(const long   chart_ID=0,    // chart's ID 
                  const string name="Button") // button name 
  { 
//--- reset the error value 
   ResetLastError(); 
//--- delete the button 
   if(!ObjectDelete(chart_ID,name)) 
     { 
      Print(__FUNCTION__, 
            ": failed to delete the button! Error code = ",GetLastError()); 
      return(false); 
     } 
//--- successful execution 
   return(true); 
  } 
//+------------------------------------------------------------------+ 
//| Delete the button                                                | 
//+------------------------------------------------------------------+

use this function ??

forextime8
399
forextime8  
any response ?
Nguyen Nga
7266
Nguyen Nga  
i think you can code it to move button to out of chart ( change X  Distance and Y Distance ).
forextime8
399
forextime8  
Nguyen Nga:
i think you can code it to move button to out of chart ( change X  Distance and Y Distance ).


button move is only move it.

but i want button minimize to minimize it.

honest_knave
Moderator
2423
honest_knave  
forextime8:


button move is only move it.

but i want button minimize to minimize it.


Either:

  • Delete close buy and close sell, then recreate them when the minimize button is clicked again
  • Hide close buy and close sell by changing their OBJPROP_TIMEFRAMES to OBJ_NO_PERIODS, then show them with OBJ_ALL_PERIODS when the minimize button is clicked again

You will need a way of knowing if close buy and close sell are minimized or not. You can either:

  • Have a global-scope variable or a static variable to act as a flag
  • Check if close buy and close sell exist (or are visible)
  • Check OBJPROP_STATE of the minimize button

forextime8
399
forextime8  
honest_knave:


Either:

  • Delete close buy and close sell, then recreate them when the minimize button is clicked again
  • Hide close buy and close sell by changing their OBJPROP_TIMEFRAMES to OBJ_NO_PERIODS, then show them with OBJ_ALL_PERIODS when the minimize button is clicked again

You will need a way of knowing if close buy and close sell are minimized or not. You can either:

  • Have a global-scope variable or a static variable to act as a flag
  • Check if close buy and close sell exist (or are visible)
  • Check OBJPROP_STATE of the minimize button


(( then recreate them when the minimize button is clicked again))

how to do this ?

//+------------------------------------------------------------------+
//+- Button Minimize ------------------------------------------------+
   if (id == CHARTEVENT_OBJECT_CLICK)
   {
   if (sparam == "ButtonMinimize")
   {
//+---
   ObjectDelete(0, "ButtonCloseBuy");
   ObjectDelete(0, "ButtonCloseSell");
//+---
   }
   ObjectSetInteger(0,"ButtonMinimize",OBJPROP_STATE,false);
   }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

this is what i done so far.

whroeder1
14781
whroeder1  
forextime8: how to do this ?
How to do what? You already know how to create the buttons. Just remember the current state. On click, if created, delete them and state is deleted, otherwise create them and state is created.
forextime8
399
forextime8  
whroeder1:
How to do what? You already know how to create the buttons. Just remember the current state. On click, if created, delete them and state is deleted, otherwise create them and state is created.

still failure to recreate on the second click....
Marco vd Heijden
Moderator
4753
Marco vd Heijden  

Please see the articles https://www.mql5.com/en/articles and look for the ones on graphical interfaces.

MQL5 Articles
MQL5 Articles
  • www.mql5.com
MQL5 Programming Articles
forextime8
399
forextime8  
Marco vd Heijden:

Please see the articles https://www.mql5.com/en/articles and look for the ones on graphical interfaces.


i had just bookmarked those pages,

but i cant found the Graphical Interfaces X: (Build 1) pages.

12
To add comments, please log in or register