ObjectGetInteger for color same for different colors?

To add comments, please log in or register
samjesse
622
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

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);
  }
Petr Nosek
754
Petr Nosek  
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); 
Alain Verleyen
35979
Alain Verleyen  
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.

To add comments, please log in or register