CButton problem with locking

 

Hello Dear Community,

does somebody know how I can solve the problem with the "Locking" of the Cbutton? I have created a CButton on a chart with the following code. I would like to have a button which you can press, but the button should not have two states (like it is actually in my code, the button has the status "not clicked" and "clicked"). After the mouse click the button schould have the status "not clicked" again. I hope this is more or less understandable.

I've looked at the example of "SimplePanel" under the indicators, this also contains three buttons that are created with the CButton class. The buttons 1 and 2 work as my button should be. But I can not find in the example how to set this.

In the example "SimplePanel the
method m_button3.Locking(true)  was called for the third button for locking. On my button, I do not call this method but it seem like the property is set to true by default. I have tried the method MyButton.Locking(false), but this does not work. Maybe I overlooked something?

I am very grateful if someone could help me.

Thank you very much!


#property version   "1.00"
#property strict
#property indicator_chart_window
#include <Controls\Button.mqh>

CButton MyButton;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(){
   MyButton.Create(0,"MyButton",0,220,20,320,60);
   //MyButton.Alignment(WND_ALIGN_RIGHT,0,0,INDENT_RIGHT,0);
   //MyButton.Locking(true);
   
   MyButton.Text("Press!");
   MyButton.ColorBackground(clrBlue);
   MyButton.Color(clrWhite);
   //MyButton.MouseFlags(false);
   //MyButton.Locking(false);
   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason){
   MyButton.Destroy();
}

 

Hi user_123!


The SimplePanel uses a dialog. This dialog handles the events.

In your program with only one button you have to handle the events yourself.

void OnChartEvent(const int id,

                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
  if (MyButton.Pressed ( ))
  {
    MyButton.Pressed (false);
    //insert the code to be executed if the button is pressed
  }
}


eddie

 
Eddie, thank you very much!
Reason: