Ver Mensaje Individual
  #1  
Antiguo 14-12-2009
LiAnTe- LiAnTe- is offline
Miembro
 
Registrado: oct 2007
Posts: 47
Reputación: 0
LiAnTe- Va por buen camino
Privileged instruction

Hola a Tod@s,

estoy creando botones en tiempo de ejecucion y le quiero asignar un OnClick a cada boton pero despues de crear este codigo....

Código Delphi [-]
procedure TGesVentasBar.FormCreate(Sender: TObject);
var vPersonalNombre : String;
    vTop            : Integer;
    vInicio         : Integer;
    vPestanya       : TWinControl;
    vBotonOnClick   : TNotifyEvent;

begin
  ListaImagenes := TStringlist.Create;

  Boton := TButton.create(self);
  boton.Caption := 'Hola';
  boton.Height := 120;
  boton.Left := 20;
  boton.Width := 130;
  boton.Enabled := True;
  Boton.visible := True;
  boton.Show;

  vTop := 1;
  vPestanya := Personal;
  vInicio := 1;

  BDades.TPersonal.Active := False;
  BDades.TPersonal.SelectSQL.Text := 'Select * from Personal where tienda = ' + '''' + BDades.TConfigTIENDA.Text + '''';
  BDades.TPersonal.Open;
  BDades.TPersonal.Active := True;
  BDades.TPersonal.First;

    While BDades.TPersonal.Eof = False do
     Begin
      vPersonalNombre := BDades.TPersonal.FieldByName('NOMBRE').AsString;
      vPersonalCodigo := BDades.TPersonal.FieldByName('CODIGO').AsInteger;

      Boton := TButton.create(self);
      boton.Parent  := vPestanya;
      boton.Caption := vPersonalNombre;
      boton.Height  := 69;
      boton.Width   := 120;
      boton.Left    := vInicio;     // Inicio
      boton.Top     := vTop;     // Altura
      boton.Enabled := True;
      Boton.visible := True;
      Boton.Tag     := vPersonalCodigo;
      Boton.OnClick := vBotonOnClick;
//      ShowMessage('Se ha pulsado el botón :' + TButton(Sender).Name);


      boton.Show;
      BDades.TPersonal.Next;
      vTop := vTop + 70;

      if vTop > 420 Then
      Begin
        vInicio := 1;
        vTop := 1;
        vPestanya := Personal2;
      end;
    end;

end;

      procedure TGesVentasBar.vBotonOnClick(Sender: TObject);
      Begin
        ShowMessage(inttostr(vPersonalCodigo));
//        Vendedor.text := vPersonalCodigo;
        Case TButton(Sender).Tag of
          1 : Showmessage(TButton(Sender).Name);
          2 : Showmessage(TButton(Sender).Name);
        end;
      end;

cuando pulso en el boton me pone Privileged instruction alguien me puede ayudar?

saludos.

Última edición por Neftali [Germán.Estévez] fecha: 14-12-2009 a las 12:50:42. Razón: Añadidas etiquetas TAG's
Responder Con Cita