Ver Mensaje Individual
  #6  
Antiguo 12-04-2007
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - Espańa
Posts: 18.298
Reputación: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
El h101, h101 son Shapes...
Entonces quedaría así:

Código Delphi [-]
procedure Tfentrada.Lh101Click(Sender: TObject);
var 
  habita:integer;
  comp:TShape
  lbl:TLabel;
  nom:String;
begin

  // Acceder al label
  lbl := TLabel(Sender);
  // Acceder al pabel relacionado con ese label
  nom := copy(lbl.Name, 2, Length(lbl.Name));
  // Con esto si el label es el lh101 nom valdrá h101, 
  // buscamos el shape con ese nombre
  comp := TShape(FindComponent(nom));



  habita:= comp.Brush.Color;

  if habita = clYellow  then begin
      habita:=clRed;
      comp.Brush.color:=habita;
      lbl.Font.Color:=clYellow
      end
  else
      begin
      habita:=clYellow;
     lbl.Font.Color:=clBlack;
      comp.Brush.color:=habita
      end
end;

Te he puesto el código de memoria, pero debe funcionar, salvo que haya cometido algun error de sintaxis. Lo más importante es que lo entiendas.
Ahora puedes hacer que todos los labels apunten a este OnClick; Si pulsas sobre lh101 funcionará con esa label y con el shape h101, si pulsas lh102 y el shape h102, y así sucesivamente...

AÑADO: Una vez que funcione, faltarían las comprobaciones de posibles errores en el FindComponent, y el los CAST.

Un saludo.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.

Última edición por Neftali [Germán.Estévez] fecha: 12-04-2007 a las 12:42:43.
Responder Con Cita