Ver Mensaje Individual
  #4  
Antiguo 11-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.318
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
Ese procedimiento es el OnClick que estás programando. En tu ejemplo, si todos los OnClick de los Labels te apuntan a este prodecimiento podrías usarlo de esta forma:

Código Delphi [-]
procedure Tfentrada.Lh101Click(Sender: TObject);
  var habita:integer;
begin

 habita:= h101.Brush.Color;

 if habita = clYellow  then
      begin
      habita:=clRed;
      h101.Brush.color:=habita;
      TLabel(Sender).Font.Color:=clYellow
      end
  else
      begin
      habita:=clYellow;
      TLabel(Sender).Font.Color:=clBlack;
      h101.Brush.color:=habita
      end
end;


Ahora queda el tema del control h101 que habría que hacer algo similar. Supongo que es un control que está relacionado con la etiqueta que se llama igual (o casi igual). Para ese caso se puede utilizar un FindComponent.

¿De qué tipo es este control?

Código Delphi [-]
var
  comp:Tcomponent;
begin
  comp := FindComponent('L' + Sender.Name);
  // esto te daría que la variable comp está apuntando al compoenente Lh101, Lh102,...
  // dependiendo si has pulsado sobre la label h101, h102,...
__________________
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: 11-04-2007 a las 19:32:59.
Responder Con Cita