Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

PrintDlgEx (comdlg32)
 
.
Summary
TODO - a short description

C# Signature:

[DllImport("comdlg32.dll", SetLastError=true)]
static extern TODO PrintDlgEx(TODO);

VB Signature:

<DllImport("comdlg32.dll", CharSet:=CharSet.Auto)> Public Shared Function PrintDlgEx(<[In](), Out()> ByVal lppd As PRINTDLGEX) As Boolean
    End Function

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

Imports System.Runtime.InteropServices

Public Class WWPrintDialog

#Region " Constants"

#Region " START_PAGE_GENERAL"

    Private Const START_PAGE_GENERAL = &HFFFFFFFF

#End Region

#End Region

#Region " ModularLevel Declarations"

#Region " m_bShowHelp"

    Private m_bShowHelp As Boolean = False

#End Region

#Region " m_bShowStatusDialog"

    Private m_bShowStatusDialog As Boolean = False

#End Region

#Region " m_bShowNetwork"

    Private m_bShowNetwork As Boolean = False

#End Region

#Region " m_bAllowSelection"

    Private m_bAllowSelection As Boolean = False

#End Region

#Region " m_bAllowSomePages"

    Private m_bAllowSomePages As Boolean = False

#End Region

#Region " m_bShowCollate"

    Private m_bShowCollate As Boolean = False

#End Region

#Region " m_hParent"

    Private m_hParent As IntPtr

#End Region

#Region " m_bAllowPrintToFile"

    Private m_bAllowPrintToFile As Boolean = False

#End Region

#Region " m_sPrinterName"

    Private m_sPrinterName As String = String.Empty

#End Region

#Region " m_Copies"

    Private m_Copies As Integer = 1

#End Region

#End Region

#Region " Delegates"

    <DllImport("comdlg32.dll", CharSet:=CharSet.Auto)> _
    Public Shared Function PrintDlgEx(<[In](), Out()> _
    ByVal lppd As PRINTDLGEX) As Boolean
    End Function

#End Region

#Region " Properties"

#Region " Parent"

    Public Property Parent() As IntPtr
    Get
        Return m_hParent
    End Get
    Set(ByVal value As IntPtr)
        m_hParent = value
    End Set
    End Property

#End Region

#End Region

#Region " Methods"

#Region " New"

    Public Sub New()

    End Sub

#End Region

#Region " ShowDialog"

    Public Function ShowDialog()
    Dim nRet As DialogResult = DialogResult.Cancel
    nRet = InvokePrintDlgEx()
    Return nRet
    End Function

#End Region

#Region " InvokePrintDlgEx"

    Public Function InvokePrintDlgEx() As DialogResult
    Dim ret As Object = Nothing
    Dim _pdex As PRINTDLGEX = New PRINTDLGEX()
    Dim _ppr As PRINTPAGERANGE = New PRINTPAGERANGE()
    Dim prnsettings As Printing.PrinterSettings = New Printing.PrinterSettings()
    _pdex.lStructSize = Marshal.SizeOf(_pdex)
    _pdex.hwndOwner = m_hParent
    _pdex.lpPageRanges = Marshal.SizeOf(_ppr)
    _pdex.hDevMode = prnsettings.GetHdevmode()
    _pdex.hDevNames = prnsettings.GetHdevnames()
    _pdex.hDC = Nothing
    _pdex.lpCallback = Nothing
    _pdex.lphPropertyPages = Nothing
    _pdex.lpPageRanges = Nothing
    _pdex.lpPrintTemplateName = Nothing
    _pdex.nCopies = 1
    _pdex.nMaxPage = 2
    _pdex.nMaxPageRanges = 10
    _pdex.nMinPage = 1
    _pdex.nPageRanges = 0
    _pdex.nMaxPageRanges = 0
    _pdex.Flags = PRINTFLAG.PD_NOSELECTION Or PRINTFLAG.PD_NOPAGENUMS
    _pdex.Flags2 = 0
    _pdex.hInstance = Nothing
    _pdex.dwResultAction = 0
    _pdex.nPropertyPages = Nothing
    _pdex.nStartPage = START_PAGE_GENERAL
    Dim bRet As Boolean = PrintDlgEx(_pdex)
    Return IIf((bRet = True), DialogResult.OK, DialogResult.Cancel)
    End Function

#End Region

#End Region

End Class

#Region " PRINTDLGEX"

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto, Pack:=1)> _

   <System.Runtime.InteropServices.ComVisible(False)> _

Public Class PRINTDLGEX

    Public lStructSize As Int32
    Public hwndOwner As IntPtr
    Public hDevMode As IntPtr
    Public hDevNames As IntPtr
    Public hDC As IntPtr = IntPtr.Zero
    Public Flags As Int32
    Public Flags2 As Int32
    Public ExclusionFlags As Int32
    Public nPageRanges As Int32
    Public nMaxPageRanges As Int32
    Public lpPageRanges As IntPtr
    Public nMinPage As Int32
    Public nMaxPage As Int32
    Public nCopies As Int32
    Public hInstance As IntPtr = IntPtr.Zero
    <MarshalAs(UnmanagedType.LPStr, SizeConst:=&H20)> _
    Public lpPrintTemplateName As String
    Public lpCallback As IntPtr = IntPtr.Zero
    Public nPropertyPages As Int32
    Public lphPropertyPages As IntPtr = IntPtr.Zero
    Public nStartPage As Int32
    Public dwResultAction As Int32

End Class

#End Region

#Region " PRINTPAGERANGE"

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto, Pack:=1)> _

   <System.Runtime.InteropServices.ComVisible(False)> _

Public Class PRINTPAGERANGE

    Public nFromPage As Int32
    Public nToPage As Int32

End Class

#End Region

#Region " PRINTFLAG"

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto, Pack:=1)> _

    <System.Runtime.InteropServices.ComVisible(False)> _

Public Class PRINTFLAG

    Public Const PD_ALLPAGES As Int32 = 0
    Public Const PD_SELECTION As Int32 = 1
    Public Const PD_PAGENUMS As Int32 = 2
    Public Const PD_NOSELECTION As Int32 = 4
    Public Const PD_NOPAGENUMS As Int32 = 8
    Public Const PD_COLLATE As Int32 = 16
    Public Const PD_PRINTTOFILE As Int32 = 32
    Public Const PD_PRINTSETUP As Int32 = 64
    Public Const PD_NOWARNING As Int32 = 128
    Public Const PD_RETURNDC As Int32 = 256
    Public Const PD_RETURNIC As Int32 = 512
    Public Const PD_RETURNDEFAULT As Int32 = 1024
    Public Const PD_SHOWHELP As Int32 = 2048
    Public Const PD_ENABLEPRINTHOOK As Int32 = 4096
    Public Const PD_ENABLESETUPHOOK As Int32 = 8192
    Public Const PD_ENABLEPRINTTEMPLATE As Int32 = 16384
    Public Const PD_ENABLESETUPTEMPLATE As Int32 = 32768
    Public Const PD_ENABLEPRINTTEMPLATEHANDLE As Int32 = 65536
    Public Const PD_ENABLESETUPTEMPLATEHANDLE As Int32 = 131072
    Public Const PD_USEDEVMODECOPIES As Int32 = 262144
    Public Const PD_USEDEVMODECOPIESANDCOLLATE As Int32 = 262144
    Public Const PD_DISABLEPRINTTOFILE As Int32 = 524288
    Public Const PD_HIDEPRINTTOFILE As Int32 = 1048576
    Public Const PD_NONETWORKBUTTON As Int32 = 2097152

End Class

#End Region

Documentation
PrintDlgEx on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions