Get QR-Code

I would like to process a generated QR-code synchronously, something like the example from the manual for Barcodes, but for QR-Codes:

procedure TForm1.Button1Click(Sender: TObject);
var
bmp: TTMSFNCBitmap;
begin
//Save into a file, for example:
bmp := TMSFNCWXBarcode1.GetBarcode('codetocreate');
try
bmp.SaveToFile('path_to\my_code.png')

How can I achieve this with TMSFNCWXQRCode?

Thanks for a hint
Dani

Hi,

The underlying JavaScript library does not make it possible to get the QR code synchronously. You can do something similar to this instead but only if you are not targeting mobile or WEB:

unit Unit30;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VCL.TMSFNCTypes, VCL.TMSFNCUtils,
  VCL.TMSFNCGraphics, VCL.TMSFNCGraphicsTypes, VCL.TMSFNCCustomControl,
  VCL.TMSFNCWebBrowser, VCL.TMSFNCCustomWEBControl, VCL.TMSFNCWXQRCode,
  Vcl.ExtCtrls;

type
  TForm30 = class(TForm)
    TMSFNCWXQRCode1: TTMSFNCWXQRCode;
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
    procedure TMSFNCWXQRCode1GetQRCode(Sender: TObject; ABitmap: TTMSFNCBitmap);
  private
    { Private declarations }
    FReceived: Boolean;
    FQRBitmap: TPicture;
  public
    { Public declarations }
  end;

var
  Form30: TForm30;

implementation

{$R *.dfm}

procedure TForm30.FormCreate(Sender: TObject);
begin
  FQRBitmap := TPicture.Create;
  FReceived := False;
  TMSFNCWXQRCode1.Text := 'Hello World';
  while not FReceived do
  begin
    Application.ProcessMessages;
    Sleep(1);
  end;

  Image1.Picture.Assign(FQRBitmap);
end;

procedure TForm30.TMSFNCWXQRCode1GetQRCode(Sender: TObject;
  ABitmap: TTMSFNCBitmap);
begin
  FQRBitmap.Assign(ABitmap);
  FReceived := True;
end;

end.