This method creates a device context.

[Visual Basic]   [ Boolean = ]imagekitcontrolname.PrintDraw.PrintCreateDC(Mode As PrintModeConstants)
[Visual C++]     [ BOOL = ]imagekitcontrolname.GetPrintDraw().PrintCreateDC(long Mode)
[VB.NET]   [ Boolean = ]imagekitcontrolname.PrintDraw.PrintCreateDC(Mode As ImageKit9(A)Lib.PrintModeConstants)
[C#.NET]   [ bool = ]imagekitcontrolname.PrintDraw.PrintCreateDC(ImageKit9(A)Lib.PrintModeConstants Mode)

* ImageKit9ALib refers to the ANSI version, ImageKit9Lib refers to the Unicode version.

Parameters

Name Explanation
Mode The method for creating the device context (from 0 to 2)

The following constants can also be used: (ikPrinterName = 0, ikPrintFileName = 1, ikDevMode = 2).

Return Value

Returns True (nonzero) if successful. Returns False (0) if unsuccessful.

Explanation

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

When the Mode parameter is 0:

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

When the Mode parameter is 1:

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

When the Mode parameter is 2:

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

 

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

When the device context is created, it will be created in the Hdc property. 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 (VisualBasic)

(1) Standard case

    ImageKit1.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

        ImageKit1.PrintDraw.PrintFileName = "C:\Test\Ik8Print.Ik8;3;2;13"

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

        ImageKit1.PrintDraw.PrintFileName = "C:\Test\IkPrint.Ik;0;2;0" or ImageKit1.PrintDraw.PrintFileName = "C:\Test\IkPrint.Ik;0;2"

 

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

Visual Basic

    Dim Ret As Boolean

    ImageKit1.PrintDraw.PrintFileName = "C:\Test\IkPrn.Ik"

    Ret = ImageKit1.PrintDraw.PrintCreateDC(ikPrintFileName)

    If Ret = False Then Exit Sub

 

    ImageKit1.PrintDraw.DocName = "ImageKit Print Sample"

    If (ImageKit1.PrintDraw.PrintStartDoc <> False) Then

        ImageKit1.PrintDraw.PrintStartPage

 

        //code to draw image or text

 

        ImageKit1.PrintDraw.PrintEndPage

        ImageKit1.PrintDraw.PrintEndDoc

    End If

    ImageKit1.PrintDraw.PrintDeleteDC

 

Visual C++

    BOOL Ret;

    ImageKit1.GetPrintDraw().SetPrintFileName("C:\\Test\\IkPrn.Ik");

    Ret = ImageKit1.GetPrintDraw().PrintCreateDC(1);

    if (Ret == FALSE) return;

 

    ImageKit1.GetPrintDraw().SetDocName("ImageKit Print Sample");

    if (ImageKit1.GetPrintDraw().PrintStartDoc() != FALSE) {

        ImageKit1.GetPrintDraw().PrintStartPage();

 

        //code to draw image or text

 

        ImageKit1.GetPrintDraw().PrintEndPage();

        ImageKit1.GetPrintDraw().PrintEndDoc();

    }

    ImageKit1.GetPrintDraw().PrintDeleteDC();

 

VB.NET

    Dim Ret As Boolean

 

    ImageKit1.PrintDraw.PrintFileName = "C:\Test\IkPrn.Ik"

    Ret = ImageKit1.PrintDraw.PrintCreateDC(ImageKit9Lib.PrintModeConstants.ikPrintFileName)

    If Ret = False Then Exit Sub

 

    ImageKit1.PrintDraw.DocName = "ImageKit Print Sample"

    If (ImageKit1.PrintDraw.PrintStartDoc() <> False) Then

    ImageKit1.PrintDraw.PrintStartPage()

 

    'code to draw image or text

 

    ImageKit1.PrintDraw.PrintEndPage()

    ImageKit1.PrintDraw.PrintEndDoc()

    End If

    ImageKit1.PrintDraw.PrintDeleteDC()

 

C#.NET

    bool Ret;

 

    ImageKit1.PrintDraw.PrintFileName = @"C:\Test\IkPrn.Ik";

    Ret = ImageKit1.PrintDraw.PrintCreateDC(ImageKit9Lib.PrintModeConstants.ikPrintFileName);

    if (Ret == false) return;

 

    ImageKit1.PrintDraw.DocName = "ImageKit Print Sample";

    if (ImageKit1.PrintDraw.PrintStartDoc() != false)

    {

    ImageKit1.PrintDraw.PrintStartPage();

 

    //code to draw image or text

 

    ImageKit1.PrintDraw.PrintEndPage();

    ImageKit1.PrintDraw.PrintEndDoc();

    }

    ImageKit1.PrintDraw.PrintDeleteDC();

 

The ImageKit9 ActiveX is a product created by Newtone Corporation