Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than comdlg32, prefix the name with the module name and a period.
<DllImport("comdlg32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function PrintDlgEx(<[In](), Out()> ByVal lppd As PRINTDLGEX) As Boolean
End Function
User-Defined Types:
None.
Alternative Managed API:
System.Windows.Forms.PrintDialog
Do you know one? Please contribute it!
Notes:
None.
Tips & Tricks:
Please add some!
VB.NET Sample Code:
Imports System.Runtime.InteropServices
Sample Code:
Public Class WWPrintDialog
Private Const START_PAGE_GENERAL = &HFFFFFFFF
Private m_bShowHelp As Boolean = False
Private m_bShowStatusDialog As Boolean = False
Private m_bShowNetwork As Boolean = False
Private m_bAllowSelection As Boolean = False
Private m_bAllowSomePages As Boolean = False
Private m_bShowCollate As Boolean = False
Private m_hParent As IntPtr
Private m_bAllowPrintToFile As Boolean = False
Private m_sPrinterName As String = String.Empty
Private m_Copies As Integer = 1
Imports System.Runtime.InteropServices
<DllImport("comdlg32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function PrintDlgEx(<[In](), Out()> ByVal lppd As PRINTDLGEX) As Boolean
End Function
Public Property Parent() As IntPtr
Get
Return m_hParent
End Get
Set(ByVal value As IntPtr)
m_hParent = value
End Set
End Property
#Region " Constants"
Public Function ShowDialog() As DialogResult
Return InvokePrintDlgEx()
End Function
#Region " START_PAGE_GENERAL"
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()
Private Const START_PAGE_GENERAL = &HFFFFFFFF
Return IIf(PrintDlgEx(_pdex), DialogResult.OK, DialogResult.Cancel)
End Function
End Class
#End Region
<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
<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
#Region " m_bShowHelp"
<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
Public Const PD_NOCURRENTPAGE As Int32 = 8388608
Public Const PD_EXCLUSIONFLAGS As Int32 = 16777216
Public Const PD_USELARGETEMPLATE As Int32 = 268435456
Public Const PD_EXCL_COPIESANDCOLLATE As Int32 = (256 Or 32768)
End Class
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
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
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
Public Const PD_NOCURRENTPAGE As Int32 = 8388608
Public Const PD_EXCLUSIONFLAGS As Int32 = 16777216
Public Const PD_USELARGETEMPLATE As Int32 = 268435456
Public Const PD_EXCL_COPIESANDCOLLATE As Int32 = (256 Or 32768)
End Class
#End Region
TODO - a short description
3/16/2007 8:17:31 AM - -63.69.129.2
Click to read this page
4/6/2008 7:23:14 AM - anonymous
TODO - a short description
3/16/2007 8:17:31 AM - -63.69.129.2
Click to read this page
4/6/2008 7:23:14 AM - anonymous
TODO - a short description
3/16/2007 8:17:31 AM - -63.69.129.2
Click to read this page
4/6/2008 7:23:14 AM - anonymous
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).