Function Reference


_WinAPI_PrintDlg

Displays a Print dialog box

#include <WinAPIDlg.au3>
_WinAPI_PrintDlg ( ByRef $tPRINTDLG )

Parameters

$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.
(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 $tagPRINTDLG may change when they are passed into
_WinAPI_PrintDlg(). This is because these members are filled on both input and output.

See Also

Search PrintDlg in MSDN Library.

Example

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

_Example()

Func _Example()
        ; Create PRINTDLG structure and set initial values for the number of copies, starting, and ending page
        Local $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
        Local $hDevNames = DllStructGetData($tPRINTDLG, 'hDevNames')
        Local $pDevNames = _MemGlobalLock($hDevNames)
        Local $tDEVNAMES = DllStructCreate($tagDEVNAMES, $pDevNames)
        ConsoleWrite('Printer: ' & _WinAPI_GetString($pDevNames + 2 * DllStructGetData($tDEVNAMES, 'DeviceOffset')))
        If DllStructGetData($tDEVNAMES, 'Default') Then
                ConsoleWrite(' (Default)' & @CRLF)
        Else
                ConsoleWrite(@CRLF)
        EndIf
        ConsoleWrite('First page: ' & DllStructGetData($tPRINTDLG, 'FromPage') & @CRLF)
        ConsoleWrite('Last page: ' & DllStructGetData($tPRINTDLG, 'ToPage') & @CRLF)
        ConsoleWrite('Copies: ' & DllStructGetData($tPRINTDLG, 'Copies') & @CRLF)

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