Recent

Author Topic: Getting Black box instead of QRCodes  (Read 765 times)

mirce.vladimirov

  • Sr. Member
  • ****
  • Posts: 256
Getting Black box instead of QRCodes
« on: February 06, 2023, 04:26:00 pm »
Hi,
I am using Lazreport plus Laz-Barcodes.
I have a TBarcodeQR on my form, and a procedure like this :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.frReport1EnterRect(Memo: TStringList; View: TfrView);
  2. var
  3. tmp : TBitmap;
  4. w,h : integer;
  5. r : TRect;
  6. begin
  7.   if (View.Name='Picture1')  then
  8.   begin
  9.     BarCodeQR1.Text := Edit1.Text;
  10.     BarCodeQR1.Update;
  11.     w := BarCodeQR1.Width;
  12.     h:= BarCodeQR1.Height;
  13.     r:= Rect(0,0,w,h);
  14.     tmp:=TBitmap.Create;
  15.     tmp.Width:=w;
  16.     tmp.Height:=h;
  17.     tmp.Canvas.CopyRect(r, BarCodeQR1.Canvas, r);
  18.     TFrPictureView(View).Picture.Bitmap.Assign(tmp);
  19.     tmp.free;
  20.   end;
  21. end;    
  22.  
  23. procedure TForm1.MyPrintingProcedure;
  24. begin
  25.   frReport1.LoadFromFile('REPORTO_qrprint1.lrf');
  26.   frVariables['teksto']:=edit1.Text;
  27.   frreport1.ShowReport;
  28. end;  
  29.  

And all works good, in my lazreport QR codes are shown correctly, as expected.


But, a problem appears when I call from another form :
Code: Pascal  [Select][+][-]
  1. procedure TThisIsAnotherForm.CallToPrint;
  2. begin
  3. Form1.MyPrintingProcedure;
  4. end;
  5.  

in this case instead of the QR code i am getting black box.

It behaves like i have to show the form with the TBarcodeQR ?!
I dont want to show the printing form, I just want to call it.

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Getting Black box instead of QRCodes
« Reply #1 on: February 06, 2023, 07:14:24 pm »
Try this:
Code: Pascal  [Select][+][-]
  1.     tmp:=TBitmap.Create;
  2.     tmp.Width:=w;
  3.     tmp.Height:=h;
  4.     tmp.Canvas.Brush.Color := clWhite;
  5.     tmp.Canvas.FillRect(0, 0, w, h);
  6.     tmp.Canvas.CopyRect(r, BarCodeQR1.Canvas, r);
  7.     ...

 

TinyPortal © 2005-2018