This function displays the Print dialog and creates a device context.
Parameters
Name | Explanation |
---|---|
hWnd | The window handle |
hDevMode | The handle of the DEVMODE structure (The handle retrieved by IKGetDevModeHandle and IKGetDevModeHandleEx) |
hDevNames | The handle of the DEVNAMES structure (The handle retrieved by IKGetDevModeHandleEx) |
IkPrnDlg | The Print dialog settings |
Return Value
Returns the device context if successful. Returns null (0) if unsuccessful.
Explanation
The IKPrintDialog function displays the Print dialog and creates a device context using the information specified. By setting hDevMode (or both the hDevMode and hDevNames), the "Print" dialog can be displayed with the printer name and printing information. To use the current printer with its existing settings then set NULL or 0 in hDevMode and hDevNames. The IKPrintDialog member variable values are displayed in the "Print" dialog when it is initialized and changes made to those settings in the "Print" dialog box are returned to the member variables when the printing is complete. hDevMode and hDevNames are updated when the device context is created when this function executes. Instead of passing the handle obtained by the IKGetDevModeHandleEx function to hDevMode and hDevNames, set 0 as an argument when obtaining both handles with this function. In that case, release hDevMode and hDevNames with the IKReleaseDevModeHandleEx function after the printing process. For more information, please refer to IKPRINT_DIALOG in the Structure Definitions and Explanations in the Ik10Print.dll, Ik10PrintA.dll, Ik10Print64.dll, Ik10Print64A.dll section. The device context is freed using the IKPrintDeleteDC function.
If the IKPrintDialog function is successful, the device context is returned which is used by the IKPrintStartDoc function.
Printing example code:
(1)C++Builder/Visual C++
HDC hDC;
IKPRINT_DIALOG IkPrnDlg;
HANDLE hDevMode, hDevNames;
hDevMode = hDevNames = NULL;
hDevMode = IKGetDevModeHandleEx("",
"Default", &hDevNames);
memset(&IkPrnDlg, 0x00,
sizeof(IkPrnDlg));
IkPrnDlg.Copies = 1;
IkPrnDlg.Options = 0x4 | 0x8 |
0x100000
//Visual C++はForm1->Set Handle into
m_hWnd
hDC = IKPrintDialog(Form1->Handle,
&hDevMode, &hDevNames, &IkPrnDlg);
if (hDC == NULL) return;
if (IKPrintStartDoc(hDC, Form1->Handle,
"", "", "", "ImageKit Print Sample") != FALSE) {
IKPrintStartPage(hDC);
//Draw
images, text, etc.
IKPrintEndPage(hDC);
IKPrintEndDoc(hDC);
}
IKPrintDeleteDC(hDC);
IKReleaseDevModeHandleEx(hDevMode,
hDevNames);
(2)Delphi
DC: HDC;
IkPrnDlg: IKPRINT_DIALOG;
hDevMode, hDevNames: THandle;
hDevMode := nil;
hDevNames := nil;
hDevMode := IKGetDevModeHandleEx('',
'Default', @hDevNames);
FillChar(IkPrnDlg, SizeOf(IkPrnDlg),
0);
IkPrnDlg.Copies := 1;
IkPrnDlg.Options := $4 or $8 or
$100000
DC := IKPrintDialog(Form1.Handle,
@hDevMode, @hDevNames, IkPrnDlg);
if DC = 0 then Exit;
if (IKPrintStartDoc(DC, Form1.Handle, '',
'', '', 'ImageKit Print Sample') <> False) then
begin
IKPrintStartPage(DC);
//Draw
images, text, etc.
IKPrintEndPage(DC);
IKPrintEndDoc(DC);
end;
IKPrintDeleteDC(DC);
IKReleaseDevModeHandleEx(hDevMode,
hDevNames);
(3)Visual Basic
Dim hDC As Long
Dim IkPrnDlg As IKPRINT_DIALOG
Dim hDevMode As Long
Dim hDevNames As Long
hDevMode = 0
hDevNames = 0
hDevMode = IKGetDevModeHandleEx("",
"Default", hDevNames)
IkPrnDlg.Copies = 1
IkPrnDlg.Options = &H4 Or &H8 Or
&H100000
hDC = IKPrintDialog(Form1.hWnd, hDevMode,
hDevNames, IkPrnDlg)
If hDC = 0 Then Exit Sub
If (IKPrintStartDoc(hDC, Form1.hWnd, "",
"", "", "ImageKit Print Sample") <> False) Then
IKPrintStartPage(hDC)
'Draw
images, text, etc.
IKPrintEndPage(hDC)
IKPrintEndDoc(hDC)
End If
IKPrintDeleteDC(hDC)
IKReleaseDevModeHandleEx(hDevMode,
hDevNames)
The ImageKit10 ActiveX is a product created by Newtone Corporation