Ver Mensaje Individual
  #3  
Antiguo 06-07-2008
Avatar de cHackAll
[cHackAll] cHackAll is offline
Baneado?
 
Registrado: oct 2006
Posts: 2.159
Reputación: 20
cHackAll Va por buen camino
Lo que pides es un Kludge, el problema es que debes manejar individualmente cada evento y tu aplicacion crece considerablemente;

Código Delphi [-]
function AsignaOnClick(Indice: string): TNotifyEvent;
begin
 case StrToInt(Indice) of
  1: Result := Form1.STTIPO1;
  2: Result := Form1.STTIPO2;
  3: Result := Form1.STTIPO3;
  4: Result := Form1.STTIPO4;
  5: Result := Form1.STTIPO5;
  6: Result := Form1.STTIPO6;
  //...
 end;
end;

La mejor solución;

Código Delphi [-]
procedure TForm1.FormCreate(Sender: TObject);
var Count: Cardinal;
begin
 Count := 66;
 while LongBool(Count) do
  with TStaticText.Create(nil) do
   begin
    Dec(Count);
    Tag := Count;

    Left := 5 + ((Count mod 10) * 50);
    Top := 18 + ((Count div 10) * 30);

    Caption := IntToStr(Count);
    Font.Name := 'Comic Sans MS';
    Font.Size := 19;

    OnClick := StaticTextClick;
    Parent := Form1;
   end;
end;

procedure TForm1.StaticTextClick(Sender: TObject);
begin
 with Sender as TStaticText do
  begin
   ShowMessage(Caption);
   case Tag of
    1: ShowMessage('Accion especial para el primer StaticText!!!');
    2: begin
        //...
       end;
    3: ;
     //...
   end;
  end;
end;

Saludos
Responder Con Cita