OBJPROP_SELECTABLE effects OBJECT_CLICK

 
int OnInit()
  {
//--- 
   ObjectCreate(0,"Name1",OBJ_BITMAP_LABEL,0,0,0);
   ObjectSetString(0,"Name1",OBJPROP_BMPFILE,1,"../Images/unchecked.bmp");
   ObjectSetString(0,"Name1",OBJPROP_BMPFILE,0,"../Images/checked.bmp");
   
   ObjectSetInteger(0,"Name1",OBJPROP_SELECTABLE,false); 
  // ObjectSetInteger(0,"Name1",OBJPROP_SELECTED,false);
   
   ObjectSetInteger(0,"Name1",OBJPROP_XDISTANCE,100);
   ObjectSetInteger(0,"Name1",OBJPROP_YDISTANCE,100);

//--- 
   return(INIT_SUCCEEDED);
  
  }
  
void OnChartEvent(const int id,         // Event identifier  
                  const long& lparam,   // Event parameter of long type
                  const double& dparam, // Event parameter of double type
                  const string& sparam) // Event parameter of string type
  {
   if(id==CHARTEVENT_OBJECT_CLICK)
     {
      Print("The mouse has been clicked on the object with name '"+sparam+"'");
          if(ObjectGetInteger(0,sparam,OBJPROP_STATE)==1)
            {ObjectSetInteger(0,sparam,OBJPROP_STATE,0);}
        else
            {
            if (ObjectGetInteger(0,sparam,OBJPROP_STATE)==0){
            ObjectSetInteger(0,sparam,OBJPROP_STATE,1);}
            }
            
         ChartRedraw();
//+------------------------------------------------------------------+
     }
  
  
  
  }

Hi folks,

I am a kind of noob in mql5 so please be patient.

I try to create a checkbox, but it drives me mad. As long as i have OBJPROP_SELECTABLE true everything works fine. If i set it to false the BMP doesnt change. 

What is the problem?

 
kkh allan:

What is the problem?

How about this?

ObjectCreate(0,"Name1",OBJ_BITMAP_LABEL,0,0,0);
ObjectSetString(0,"Name1",OBJPROP_BMPFILE,1,"\\Images\\unchecked.bmp");
//ObjectSetString(0,"Name1",OBJPROP_BMPFILE,0,"\\Images\\checked.bmp");
if(ObjectGetInteger(0,sparam,OBJPROP_STATE)==1)
{
   ObjectSetString(0,"Name1",OBJPROP_BMPFILE,0,"\\Images\\checked.bmp");
   //ObjectSetInteger(0,sparam,OBJPROP_STATE,0);
}
else
 if(ObjectGetInteger(0,sparam,OBJPROP_STATE)==0)
{
   ObjectSetString(0,"Name1",OBJPROP_BMPFILE,1,"\\Images\\unchecked.bmp");
   //ObjectSetInteger(0,sparam,OBJPROP_STATE,1);}
}
 

Ah, now I see.. 

It works fine. Thanks a lot :)