Method: DrawTo - Synatx 2

Draws a barcode symbol on the specified canvas. The barcode symbol is specified in the parameters of this method.

Syntax:

type

{ Defined in the pCore1D unit }

TDisplayText = (dtNone, dtBarcode, dtFullEncoded);

{ Defined in the pCore1D unit }

TTextPosition = (tpTopIn, tpTopOut, tpBottomIn, tpBottomOut);

{ Defined in the pCore1D unit }

TTextAlignment = (taLeft, taCenter, taRight, taJustify, taLeftQuietZone, taCenterQuietZone, taRightQuietZone, taJustifyQuietZone, taCustom);

function DrawTo(Canvas: TCanvas; Left, Top: Integer; Barcode: string; AutoCheckDigit: Boolean; BarColor, SpaceColor: TColor; BarcodeTextDefine: TBarcodeTextDefine; Ratio: Double; Module: Integer = 0; Height: Integer = 0; Angle: Integer = 0; HDPI: Integer = 0; VDPI: Integer = 0): Integer; overload; virtual;

Description:

On the specified canvas, draws a barcode symbol that is specified in the parameters of this method.

Parameters:
Return:

See diagram:

DrawTo (Syntax 2)

Note:

For Delphi 3, the method overload and default value of parameter aren't supported, so the method name is changed to DrawTo2, and the parameters Module, Height, Angle, HDPI, and VDPI are required.

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