Redraws current barcode symbol in the TImage, TQRImage, or TQRGzImage control that's specified by the Image property.
function Draw: Boolean; virtual;
The method redraws the barcode symbol that is specified in the barcode component to the TImage, TQRImage, or TQRGzImage control that's specified by the Image property.
If the method succeeds, the return value is true.
If the Image property is not set, the return value is false.
If the length of Barcode or Data (only for Delphi/C++ Builder 2009 or later) property value is invalid, the return value is false, corresponding to the OnInvalidLength or OnInvalidDataLength (only for Delphi/C++ Builder 2009 or later) event will occur.
If there is any invalid character in the Barcode or Data (only for Delphi/C++ Builder 2009 or later) property value, the return value is false, corresponding to the OnInvalidChar or OnInvalidDataChar (only for Delphi/C++ Builder 2009 or later) event will occur.
The method uses GetDeviceCaps function to retrieves device-specific information for the specified device. When using Printer.Canvas as the target cvanvas, it will fail if a default printer is not set in Windows. Please ensure that a default printer is specified in Windows:
Set default printer for current application:
uses Winapi.Printers;
procedure SetAppPrinter(const PrinterName: string);
var
Idx: Integer;
begin
Idx := Printer.Printers.IndexOf(PrinterName);
if Idx <> -1 then
Printer.PrinterIndex := Idx
else
ShowMessage('Printer not found!');
end;
Set the global default printer.
uses Winapi.WinSpool;
procedure SetWindowsDefaultPrinter(const PrinterName: string);
begin
if SetDefaultPrinter(PChar(PrinterName)) then
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0)
else
RaiseLastOSError;
end;