函数参考


_WinAPI_PrintDlg

Displays a Print dialog box.

#Include <WinAPIEx.au3>
_WinAPI_PrintDlg ( ByRef $tPRINTDLG )

参数

$tPRINTDLG $tagPRINTDLG structure that contains information used to initialize the dialog box. When the function
returns, it contains information about the user's selections. This structure must be initialized
before function call.

(查看MSDN得到更多信息)

返回值

成功: 返回 1.
Failure 0 and sets the @error flag to non-zero, @extended flag may contain the dialog box error code.

注意/说明

Note that the values of "hDevMode" and "hDevNames" member in $tagPRINTDLG may change when they are passed into
_WinAPI_PrintDlg(). This is because these members are filled on both input and output.

相关

详情参考

在MSDN中搜索


示例/演示


#Include <APIConstants.au3>
#Include <Memory.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

Global $tPRINTDLG, $tDEVNAMES, $hDevNames, $pDevNames

; Create PRINTDLG structure and set initial values for the number of copies, starting, and ending page
$tPRINTDLG = DllStructCreate($tagPRINTDLG)
DllStructSetData($tPRINTDLG, 'Size', DllStructGetSize($tPRINTDLG))
DllStructSetData($tPRINTDLG, 'Flags', $PD_PAGENUMS)
DllStructSetData($tPRINTDLG, 'FromPage', 2)
DllStructSetData($tPRINTDLG, 'ToPage', 3)
DllStructSetData($tPRINTDLG, 'MinPage', 1)
DllStructSetData($tPRINTDLG, 'MaxPage', 9)
DllStructSetData($tPRINTDLG, 'Copies', 4)

; Create Print dialog box
If Not _WinAPI_PrintDlg($tPRINTDLG) Then
    Exit
EndIf

; Show results
$hDevNames = DllStructGetData($tPRINTDLG, 'hDevNames')
$pDevNames = _MemGlobalLock($hDevNames)
$tDEVNAMES = DllStructCreate($tagDEVNAMES, $pDevNames)
ConsoleWrite('Printer: ' & _WinAPI_GetString($pDevNames + 2 * DllStructGetData($tDEVNAMES, 'DeviceOffset')))
If DllStructGetData($tDEVNAMES, 'Default') Then
    ConsoleWrite(' (Default)' & @CR)
Else
    ConsoleWrite(@CR)
EndIf
ConsoleWrite('First page: ' & DllStructGetData($tPRINTDLG, 'FromPage') & @CR)
ConsoleWrite('Last page: ' & DllStructGetData($tPRINTDLG, 'ToPage') & @CR)
ConsoleWrite('Copies: ' & DllStructGetData($tPRINTDLG, 'Copies') & @CR)

; Free global memory objects that contains a DEVMODE and DEVNAMES structures
_MemGlobalFree(DllStructGetData($tPRINTDLG, 'hDevMode'))
_MemGlobalFree($hDevNames)