Download MetaTrader 5

Why don't Comments (buy, sell or closeall) display when I click on the buttons??

To add comments, please log in or register
ccou
200
ccou  

Hi!  Thanks !

#property strict
#include <stdlib.mqh>

#include <Controls\Dialog.mqh>
#include <Controls\Button.mqh>

extern string sVisualSettings="<<=== Visualization Settings ===>>"; // <<=== Visualization Settings ===>>

extern color BuyFontColor=clrWhite; //Buy Btn Font Color
extern color BuyBGColor=clrGreen; //Buy Btn BG Color
extern color BuyBorderColor=clrDarkGreen; //Buy Btn Border Color

extern color SellFontColor=clrWhite; //Sell Btn Font Color
extern color SellBGColor=clrRed; //Sell Btn BG Color
extern color SellBorderColor=clrMaroon; //Sell Btn Border Color

extern color CloseAllFontColor=clrWhite; //Close All Btn Font Color
extern color CloseAllBGColor=clrGray; //Close All Btn BG Color
extern color CloseAllBorderColor=clrDimGray; //Close All Btn Border Color

CButton cbBuy,cbSell,cbCloseAll;

//+------------------------------------------------------------------+
int OnInit()
  {
//---
   tmpDialog.Create(0,"",0,0,0,0,0);
   tmpDialog.Destroy(2);

      int FontSize=14;

      cbBuy.Create(0,"cbBuy",0,             400,200,  200,100);
      cbBuy.Text("BUY");
      cbBuy.FontSize(FontSize);
      cbBuy.Color(BuyFontColor);
      cbBuy.ColorBackground(BuyBGColor);
      cbBuy.ColorBorder(BuyBorderColor);


      cbSell.Create(0,"cbSell",0,           600,200,  400,100);
      cbSell.Text("SELL");
      cbSell.FontSize(FontSize);
      cbSell.Color(SellFontColor);
      cbSell.ColorBackground(SellBGColor);
      cbSell.ColorBorder(SellBorderColor);


      cbCloseAll.Create(0,"cbCloseAll",0,   600,100,    200,0);
      cbCloseAll.Text("Close ALL");
      cbCloseAll.FontSize(FontSize);
      cbCloseAll.Color(CloseAllFontColor);
      cbCloseAll.ColorBackground(CloseAllBGColor);
      cbCloseAll.ColorBorder(CloseAllBorderColor);

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
      cbBuy.Destroy();
      cbSell.Destroy();
      cbCloseAll.Destroy();
  }
//+------------------------------------------------------------------+

void OnTick()
  {

  }

//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   int Buys=0,Sells=0;

   cbCloseAll.OnEvent(id,lparam,dparam,sparam);
   cbBuy.OnEvent(id,lparam,dparam,sparam);
   cbSell.OnEvent(id,lparam,dparam,sparam);

   if(id==CHARTEVENT_OBJECT_CLICK && sparam=="cbCloseAll")
     {
      Comment("CloseALL");
     }
   else
   if(id==CHARTEVENT_OBJECT_CLICK && sparam=="cbBuy")
     {
      Comment("Buy");
     }
   else
   if(id==CHARTEVENT_OBJECT_CLICK && sparam=="cbSell")
     {
      Comment("Sell");
     }

   if(id==CHARTEVENT_CLICK)
     {
      cbBuy.Pressed(false);
      cbSell.Pressed(false);
      cbCloseAll.Pressed(false);
     }

   MoveButtons();
  }
//+------------------------------------------------------------------+

void MoveButtons()
  {
      cbBuy.Move(400,200);
      cbSell.Move(600,200);
      cbCloseAll.Move(600,100);
  }
//+------------------------------------------------------------------+
class TempDialog : public CAppDialog
  {
private:
   CButton           b1;
public:
                     TempDialog(void);
                    ~TempDialog(void);
   virtual bool      Create();
   virtual bool      OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);
protected:
   void              F1(void);
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
EVENT_MAP_BEGIN(TempDialog)
ON_EVENT(ON_CLICK,b1,F1)
EVENT_MAP_END(CAppDialog)
TempDialog::TempDialog(void)
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
TempDialog::~TempDialog(void)
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool TempDialog::Create()
  {
   if(!CAppDialog::Create(0,"",0,0,0,0,0))
      return(false);
   return(true);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
TempDialog::F1(void)
  {
//
  }
TempDialog tmpDialog;
//+------------------------------------------------------------------+
//| End
//+------------------------------------------------------------------+
To add comments, please log in or register