ObjectGetInteger for color same for different colors?

 

Hi

I expected to get a different integer for different colors in order to be able to change the color of a label from green to gray but only if it is currently green. the code below is returning the same integer regardless of the the color. Why? and how to go about it?

Thanks

string lAlert = "lAlert";
int OnInit() { 
   makeLable(clrGray); // try with clrGreen
   
  int obj_color_integer = ObjectGetInteger(0,lAlert,OBJPROP_COLOR,0); 
  Print("color obj int " + obj_color_integer);  //8421504 gray, or green gives the same number, why?  
  
   return(INIT_SUCCEEDED); 
}

void makeLable(color myColor)
  {
   ObjectCreate(lAlert,OBJ_RECTANGLE_LABEL,0,0,0);
   ObjectSet(lAlert,OBJPROP_CORNER,2);
   ObjectSetInteger(0,lAlert,OBJPROP_XSIZE,20);
   ObjectSetInteger(0,lAlert,OBJPROP_YSIZE,20);
   ObjectSetInteger(0,lAlert,OBJPROP_BGCOLOR,myColor);
   ObjectSetInteger(0,lAlert,OBJPROP_BACK,false);
   ObjectSet(lAlert,OBJPROP_XDISTANCE,10);
   ObjectSet(lAlert,OBJPROP_YDISTANCE,30);
  }
 
samjesse:

Hi

I expected to get a different integer for different colors in order to be able to change the color of a label from green to gray but only if it is currently green. the code below is returning the same integer regardless of the the color. Why? and how to go about it?

Thanks

Pay attention what you want to get. Background color isn't the same as foreground color.
int obj_color_integer = ObjectGetInteger(0,lAlert,OBJPROP_BGCOLOR,0); 
 
samjesse:

Hi

I expected to get a different integer for different colors in order to be able to change the color of a label from green to gray but only if it is currently green. the code below is returning the same integer regardless of the the color. Why? and how to go about it?

Thanks

Already discussed, please use the search engine before posting.

You just created your object, it's not yet draw/updated yet on the chart. Anyway your code doesn't make sense, you know the color, you just set it.

Reason: