This method creates a device context.

[C++Builder]   [ bool = ]imagekitcontrolname->PrintDraw->PrintCreateDC(TVIkPrintMode Mode)
[Delphi]   [ Boolean = ]imagekitcontrolname.PrintDraw.PrintCreateDC(Mode: TVIkPrintMode)

Parameters

Name Explanation
Mode The method for creating the device context

Return Value

Returns True if successful. Returns False if unsuccessful.

Explanation

The PrintCreateDC method creates a device context in one of three ways.

When the Mode parameter is vikPrinterName:

    The device context is created for the printer that has its name set in the PrinterName property.

When the Mode parameter is vikPrintFileName:

    The device context is created for the printer that is listed in the file set in the PrintFileName  property.

When the Mode parameter is vikDevMode:

    The device context is created from the handle of the DEVMODE structure that is set in the DevMode property and the DEVNAMES structure set in the DevNames property.

 

To print with the default printer using the current settings, set the Mode parameter to vikPrintFileName and in the PrintFileName property set, "Default".

When the device context is created, it will be created in the Handle property. Also, the resolution is set in the XResolution and YResolution properties. The device context is freed using the PrintDeleteDC method.

As an extension to the PrintFileName property, it's possible to print without changing the settings that have been already set in the printer information file by adding the print number of copies, the printer orientation, and the paper size (in that order) in the back of the file name before executing the PrintCreateDC method. The delimiter for the settings is a semicolon (;). These settings (the the print number of copies, the printer orientation, and the paper size) can be omitted.

Note: Enter a zero (0) into the properties that you do not want to change. For more information please refer to the PrintFileName property as well as the Copies, PaperSize and Orientation properties.

The printer orientation: ( ) The explanation contained in the parentheses has the same meaning as the constants used by WindowsAPI.

Value Explanation
1 Vertical (DMORIENT_PORTRAIT)
2 Horizontal (DMORIENT_LANDSCAPE)

the paper size: ( ) The explanation contained in the parentheses has the same meaning as the constants used by WindowsAPI.

Value Explanation
8 A3(DMPAPER_A3)
9 A4(DMPAPER_A4)
12 B4(DMPAPER_B4)
13 B5(DMPAPER_B5)

 

Sample Code: Using a printer setting file (IkPrint.Ik) to print (Delphi)

(1) Standard case

    VImageKit1.PrintDraw.PrintFileName := 'C:\Test\IkPrint.Ik';

(2) Using the extended functions of the printer setting file

    A) Number of copies= 3, Orientation = Horizontal, PaperSize = B5

        VImageKit1.PrintDraw.PrintFileName := 'C:\Test\IkPrint.Ik;3;2;13';

    B) Retrieve the number of copies and paper size from the printer file but the orientation to horizontal

        VImageKit1.PrintDraw.PrintFileName := 'C:\Test\IkPrint.Ik;0;2;0'; or VImageKit1.PrintDraw.PrintFileName := 'C:\Test\IkPrint.Ik;0;2';

 

Sample Code: Using a printer setting file (IkPrn.Ik) to print

In C++Builder

bool Ret;

VImageKit1->PrintDraw->PrintFileName = "C:\\Test\\IkPrn.Ik";
Ret = VImageKit1->PrintDraw->PrintCreateDC(vikPrintFileName);
if (Ret == false) return;

VImageKit1->PrintDraw->DocName = "ImageKit Print Sample";
if (VImageKit1->PrintDraw->PrintStartDoc() != false) {
   VImageKit1->PrintDraw->PrintStartPage();

   //Draw text or image here

   VImageKit1->PrintDraw->PrintEndPage();
   VImageKit1->PrintDraw->PrintEndDoc();
}
VImageKit1->PrintDraw->PrintDeleteDC();

In Delphi

Ret: Boolean;

VImageKit1.PrintDraw.PrintFileName := 'C:\Test\IkPrn.Ik';
Ret := VImageKit1.PrintDraw.PrintCreateDC(vikPrintFileName);
if Ret = False then Exit;

VImageKit1.PrintDraw.DocName := 'ImageKit Print Sample';
if (VImageKit1.PrintDraw.PrintStartDoc <> False) then
begin
   VImageKit1.PrintDraw.PrintStartPage;

   //Draw text or image here

   VImageKit1.PrintDraw.PrintEndPage;
   VImageKit1.PrintDraw.PrintEndDoc;
end;
VImageKit1.PrintDraw.PrintDeleteDC;

Differences between the ImageKit7/8/9

In VCL the constants contain a "v". In ActiveX, the constants are: ikPrinterName, ikPrintFileName, ikDevMode.

Differences with ImageKit 7/8/9 ActiveX/VCL

If this method is successful, the device context resolution is set in the XResolution and YResolution properties.

 

The ImageKit10 VCL is a product created by Newtone Corporation