# Function Reference

# _WinAPI_PageSetupDlg

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

#include <WinAPIDlg.au3>
_WinAPI_PageSetupDlg ( ByRef $tPAGESETUPDLG )

## Parameters

$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. (See MSDN for more information)

## Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended flag may contain the dialog box error code.

## Remarks

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().

## Related

_WinAPI_PrintDlg, _WinAPI_PrintDlgEx

## See Also

Search PageSetupDlg in MSDN Library.

## Example

    #include <Memory.au3>
    #include <WinAPIDlg.au3>

    ; Create PAGESETUPDLG structure and set initial margin values for 10.00 mm at all
    Local $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' & @CRLF)
    ConsoleWrite('Paper height: ' & DllStructGetData($tPAGESETUPDLG, 'PaperHeight') / 100 & ' mm' & @CRLF)
    ConsoleWrite('Margin left: ' & DllStructGetData($tPAGESETUPDLG, 'MarginLeft') / 100 & ' mm' & @CRLF)
    ConsoleWrite('Margin top: ' & DllStructGetData($tPAGESETUPDLG, 'MarginTop') / 100 & ' mm' & @CRLF)
    ConsoleWrite('Margin right: ' & DllStructGetData($tPAGESETUPDLG, 'MarginRight') / 100 & ' mm' & @CRLF)
    ConsoleWrite('Margin bottom: ' & DllStructGetData($tPAGESETUPDLG, 'MarginBottom') / 100 & ' mm' & @CRLF)

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