Ver Mensaje Individual
  #2  
Antiguo 24-11-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola.

Creo que tendrías que crear otro arreglo constante con la traducción de los nombres.

Un ejemplo:
Código Delphi [-]
const
  SPACOL: array[0..17] of string = ('Agua','Negro','Azul','Gris oscuro',
    'Fucsia','Gris','Verde','Lima','Gris claro','Marrón','Azul marino',
    'Verde oliva','Púrpura','Rojo','Plateado','Cerceta','Blanco','Amarillo');
  ENGCOL: array[0..17] of TColor = (clAqua, clBlack, clBlue, clDkGray,
    clFuchsia, clGray, clGreen, clLime, clLtGray, clMaroon, clNavy,
    clOlive, clPurple, clRed, clSilver, clTeal, clWhite,  clYellow);

procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
begin
  with ComboBox1 do
  begin
    Style:= csOwnerDrawFixed;
    for i:= 0 to 17 do AddItem(SPACOL[i], TObject(ENGCOL[i]));
  end;
end;

procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with Control as TComboBox do
  begin
    if odSelected in State then
      Canvas.Brush.Color:= clHighlight
    else
      Canvas.Brush.Color:= clWhite;
    Canvas.FillRect(Rect);
    Canvas.TextOut(Rect.Left + 24, Rect.Top, SPACOL[Index]);
    Canvas.Brush.Color:= TColor(Items.Objects[Index]);
    Canvas.Rectangle(Rect.Left + 1, Rect.Top + 1, Rect.Left + 21, Rect.Bottom - 1);
  end;
end;

// Aplicar color seleccionado a un TPanel
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
   with TComboBox(Sender) do
     if ItemIndex <> -1 then
       Panel1.Color:= TColor(Items.Objects[ItemIndex]);
end;

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita