函数参考


_WinAPI_PageSetupDlg

Creates a Page Setup dialog box that enables the user to specify the attributes of a printed page.

#Include <WinAPIEx.au3>
_WinAPI_PageSetupDlg ( ByRef $tPAGESETUPDLG )

参数

$tPAGESETUPDLG $tagPAGESETUPDLG structure that contains information used to initialize the Page Setup dialog box.
The structure receives information about the user's selections when the function returns,
and 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 $tagPAGESETUPDLG may change when they are passed into
_WinAPI_PageSetupDlg(). This is because these members are filled on both input and output.

Starting with Windows Vista, the _WinAPI_PageSetupDlg() does not contain the "Printer" button. To switch printer
selection, use _WinAPI_PrintDlg() or _WinAPI_PrintDlgEx().

相关

详情参考

在MSDN中搜索


示例/演示


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

Opt('MustDeclareVars', 1)

Global $tPAGESETUPDLG

; Create PAGESETUPDLG structure and set initial margin values for 10.00 mm at all
$tPAGESETUPDLG = DllStructCreate($tagPAGESETUPDLG)
DllStructSetData($tPAGESETUPDLG, 'Size', DllStructGetSize($tPAGESETUPDLG))
DllStructSetData($tPAGESETUPDLG, 'Flags', BitOR($PSD_INHUNDREDTHSOFMILLIMETERS, $PSD_MARGINS))
DllStructSetData($tPAGESETUPDLG, 'MarginLeft', 10 * 100)
DllStructSetData($tPAGESETUPDLG, 'MarginTop', 10 * 100)
DllStructSetData($tPAGESETUPDLG, 'MarginRight', 10 * 100)
DllStructSetData($tPAGESETUPDLG, 'MarginBottom', 10 * 100)

; Create Page Setup dialog box
If Not _WinAPI_PageSetupDlg($tPAGESETUPDLG) Then
    Exit
EndIf

; Show results
ConsoleWrite('Paper width: ' & DllStructGetData($tPAGESETUPDLG, 'PaperWidth') / 100 & ' mm' & @CR)
ConsoleWrite('Paper height: ' & DllStructGetData($tPAGESETUPDLG, 'PaperHeight') / 100 & ' mm' & @CR)
ConsoleWrite('Margin left: ' & DllStructGetData($tPAGESETUPDLG, 'MarginLeft') / 100 & ' mm' & @CR)
ConsoleWrite('Margin top: ' & DllStructGetData($tPAGESETUPDLG, 'MarginTop') / 100 & ' mm' & @CR)
ConsoleWrite('Margin right: ' & DllStructGetData($tPAGESETUPDLG, 'MarginRight') / 100 & ' mm' & @CR)
ConsoleWrite('Margin bottom: ' & DllStructGetData($tPAGESETUPDLG, 'MarginBottom') / 100 & ' mm' & @CR)

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