Ver Mensaje Individual
  #1  
Antiguo 08-08-2011
Avatar de richy08
richy08 richy08 is offline
Miembro
 
Registrado: may 2007
Ubicación: Bucerias, Nayarit Mexico
Posts: 529
Reputación: 18
richy08 Va por buen camino
Asignar a tbitbtn evento en tiempo de ejecucion

buenas tardes compañeros les explico un poco lo que quiero hacer, con un query estoy poniendo en tiempo de ejecucion bitbtn por cada categoria que encuentro en una bd, a estos bitbtn creados en tiempo de ejecucion quiero asignarles un evento, pero dicho evento necesito que lleve como parametro el id (lo obtengo del query) de cada categoria para lo cual uso el siguiente codigo

Código Delphi [-]
       Left:=8;
       top:=8;
       Qry_Line.Close;
       Qry_Line.Open;
       Seleccion:=0;
       Seleccion:=Qry_Line.RecordCount;

       While ido
       begin
          boton := TBitBtn.Create(nil);
          boton.Name:='btb'+inttostr(Qry_Line.fieldbyname('idlinea').Value);
          boton.Hint:=Qry_Line.fieldbyname('descripcion').Value;
          boton.Left:= left;
          boton.Top:=8;
          boton.Width:=81;
          boton.Height:=57;
          boton.Parent:=Pnl_line;
          linea:= Qry_Line.fieldbyname('idlinea').AsInteger;
          boton.OnClick:=categoriallena(linea);

          if FileExists('C:\Proyectos Delphi\Zibarita TouchScreen\Image\'+inttostr(Qry_Line.fieldbyname('idlinea').Value)+'.bmp') then
          begin
            boton.Glyph.LoadFromFile('C:\Proyectos Delphi\Zibarita TouchScreen\Image\'+inttostr(Qry_Line.fieldbyname('idlinea').Value)+'.bmp');
            boton.Caption:='';
          end
          else
            boton.Caption:=Qry_Line.fieldbyname('idlinea').Value;



         Qry_Line.next;
         left:=left+86;
         i:=i+1;
       end;
      end;

pero no logro hacer que compile, el motivo de llevar el id de la categoria es por que al ejecutar un click sobre el boton quiero que en otro tpanel mostrar las diferentes sub categorias, alguien me podria indicar como ligarle correctamente el evento en tiempo de ejecucion, y como deberia ser la declaracion del procedure que se encargara de mostrar las sub categorias, ahora lo tengo asi

Código Delphi [-]
procedure TFrm_Main.categoriallena(x: integer);
begin
  showmessage(inttostr(x));

end;

gracias por cualquier comentario
Responder Con Cita