Method: Draw

Redraws current barcode symbol in the TImage, TQRImage, or TQRGzImage control that's specified by the Image property.

Syntax:

function Draw(ReEncode: Boolean = False): Boolean; virtual;

Description:

The method redraws the barcode symbol to the TImage, TQRImage, or TQRGzImage control that's specified by the Image property. The barcode symbol is specified in the properties of this barcode component.

For the TBarcode2D_CCA, TBarcode2D_CCB, and TBarcode2D_CCC barcode components, if the Linear property is set, the 2D symbol and the linear symbol are assembled to generate an EAN.UCC composite barcode symbol. Both of them will be drawn in the TImage, TQRImage, or TQRGzImage control.

Parameter:
Return:
Note:

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;

Contents