This method displays the Print dialog box and creates a device context.
Parameters
None
Return Value
Returns True (nonzero) if successful. Returns False (0) if unsuccessful.
Explanation
The PrintDialog method displays the Print dialog box and creates a device context using those settings. By executing the GetDevModeHandle method and retrieving the DevMode property and the DevNames property, the "Print" dialog box can be displayed with the printer name and printing conditions. To use the current printer with its existing settings then it is not necessary to execute the GetDevModeHandle method.
The Collate, Copies, FromPage, ToPage, MaxPage, MinPage, Options, PrintRange, and PrintToFile property values are displayed in the "Print" dialog box when it is initialized and changes made to those settings in the "Print" dialog box are returned to the properties when the printing is complete.
If the PrintDialog method is successful, the printer device context is set into the Hdc property, the information provided by the DevMode and DevNames properties is updated. Also, the device context resolution is set in the XResolution and YResolution properties.
The acquired device context is deleted with the PrintDeleteDC method, and the DevMode property and DevNames property are released with the ReleaseDevModeHandle method.
The PrintDialog method corresponds to the Print Control's PrintDlg method in earlier versions of the ImageKit.
Sample code: Printing:
Visual Basic
Dim Ret As Boolean
ImageKit1.PrintDraw.ClearProperty
ImageKit1.PrintDraw.Copies = 1
ImageKit1.PrintDraw.Options = &H4 Or &H8 Or &H100000
Ret = ImageKit1.PrintDraw.PrintDialog
If Ret = 0 Then Exit Sub
ImageKit1.PrintDraw.DocName = "ImageKit Print Sample"
If (ImageKit1.PrintDraw.PrintStartDoc <> False) Then
ImageKit1.PrintDraw.PrintStartPage
'code for displaying image or text
ImageKit1.PrintDraw.PrintEndPage
ImageKit1.PrintDraw.PrintEndDoc
End If
ImageKit1.PrintDraw.PrintDeleteDC
ImageKit1.PrintDraw.ReleaseDevModeHandle
Visual C++
BOOL Ret;
ImageKit1.GetPrintDraw().ClearProperty();
ImageKit1.GetPrintDraw().SetCopies(1);
ImageKit1.GetPrintDraw().SetOptions(0x4 | 0x8 | 0x100000);
Ret = ImageKit1.GetPrintDraw().PrintDialog();
if (Ret == FALSE) return;
ImageKit1.GetPrintDraw().SetDocName("ImageKit Print Sample");
if (ImageKit1.GetPrintDraw().PrintStartDoc() != FALSE) {
ImageKit1.GetPrintDraw().PrintStartPage();
//code for displaying image or text
ImageKit1.GetPrintDraw().PrintEndPage();
ImageKit1.GetPrintDraw().PrintEndDoc();
}
ImageKit1.GetPrintDraw().PrintDeleteDC();
ImageKit1.GetPrintDraw().ReleaseDevModeHandle();
VB.NET
Dim Ret As Boolean
ImageKit1.PrintDraw.ClearProperty()
ImageKit1.PrintDraw.Copies = 1
ImageKit1.PrintDraw.Options = &H4 Or &H8 Or &H100000
Ret = ImageKit1.PrintDraw.PrintDialog()
If Ret = False Then Exit Sub
ImageKit1.PrintDraw.DocName = "ImageKit Print Sample"
If (ImageKit1.PrintDraw.PrintStartDoc() <> False) Then
ImageKit1.PrintDraw.PrintStartPage()
'code for displaying image or text
ImageKit1.PrintDraw.PrintEndPage()
ImageKit1.PrintDraw.PrintEndDoc()
End If
ImageKit1.PrintDraw.PrintDeleteDC()
ImageKit1.PrintDraw.ReleaseDevModeHandle()
C#.NET
bool Ret;
ImageKit1.PrintDraw.ClearProperty();
ImageKit1.PrintDraw.Copies = 1;
ImageKit1.PrintDraw.Options = 0x4 | 0x8 | 0x100000;
Ret = ImageKit1.PrintDraw.PrintDialog();
if (Ret == false) return;
ImageKit1.PrintDraw.DocName = "ImageKit Print Sample";
if (ImageKit1.PrintDraw.PrintStartDoc() != false)
{
ImageKit1.PrintDraw.PrintStartPage();
//code for displaying image or text
ImageKit1.PrintDraw.PrintEndPage();
ImageKit1.PrintDraw.PrintEndDoc();
}
ImageKit1.PrintDraw.PrintDeleteDC();
ImageKit1.PrintDraw.ReleaseDevModeHandle();
Differences between ImageKit7/8/9
If this method succeeds, the information indicated by DevMode property and DevNames property is updated, and the resolution of the device context will be set in the XResolution and YResolution properties.