unit UnitEtiqueta;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, Db, DBTables, QRCtrls, QuickRpt, ExtCtrls;

type
  Tfetiqueta = class(TForm)
    Panel1: TPanel;
    Quicketiqueta: TQuickRep;
    QRBand3: TQRBand;
    QRDBText14: TQRDBText;
    L1: TQRLabel;
    L2: TQRLabel;
    L3: TQRLabel;
    L5: TQRLabel;
    L4: TQRLabel;
    BitBtn1: TBitBtn;
    T5: TEdit;
    T4: TEdit;
    T3: TEdit;
    T2: TEdit;
    T1: TEdit;
    ltitulo: TLabel;
    Label1: TLabel;
    procedure BitBtn1Click(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure QuicketiquetaBeforePrint(Sender: TCustomQuickRep;
      var PrintReport: Boolean);
    procedure QuicketiquetaNeedData(Sender: TObject;
      var MoreData: Boolean);
  private
    { Private declarations }
  public

    ContBarra:String;
    SomeList:TStringList;
    CurrentIndex: integer;
    { Public declarations }
  end;

var
  fetiqueta: Tfetiqueta;

implementation

{$R *.DFM}

procedure Tfetiqueta.BitBtn1Click(Sender: TObject);
Var
 i:Integer;
begin


  ContBarra :='20';
  if InputQuery ('Etiquetas', 'Digite o nš de etiquetas a ser impressa',ContBarra)then
begin

       L1.Caption := T1.Text;
       L2.Caption := T2.Text;
       L3.Caption := T3.Text;
       L4.Caption := T4.Text;
       L5.Caption := T5.Text;


  SomeList := TStringlist.Create;

  for i := 0 to StrToInt(fetiqueta.ContBarra) do
    SomeList.Add('Line ' + IntToStr(i));

    Quicketiqueta.Previewmodal;

     end;
end;

procedure Tfetiqueta.FormKeyPress(Sender: TObject; var Key: Char);
begin

 if key=#13 then
     Perform(WM_nextdlgctl,0,0);

 if key=#27 then
     Perform(WM_nextdlgctl,0,1);


end;

procedure Tfetiqueta.QuicketiquetaBeforePrint(Sender: TCustomQuickRep;
  var PrintReport: Boolean);
begin
          CurrentIndex := 1;
end;

procedure Tfetiqueta.QuicketiquetaNeedData(Sender: TObject;
  var MoreData: Boolean);
begin
  MoreData := (CurrentIndex < fetiqueta.SomeList.Count);

  if MoreData then
  begin
    Label1.Caption := fetiqueta.SomeList[CurrentIndex];

    // Here's how to set the progress bar
    quicketiqueta.QRPrinter.Progress := (Longint(CurrentIndex) * 100) div fetiqueta.SomeList.Count;
  end
  else
    quicketiqueta.QRPrinter.Progress := 100;

  Inc(CurrentIndex);

end;

end.
