using System;
using System.Runtime.InteropServices;
using Vanara.Extensions;
using Vanara.InteropServices;
using static Vanara.PInvoke.Kernel32;
using static Vanara.PInvoke.User32;
namespace Vanara.PInvoke
{
/// Items from the ComDlg32.dll
public static partial class ComDlg32
{
///
/// A set of bit flags that you can use to initialize the Color dialog box. When the dialog box returns, it sets these flags to
/// indicate the user's input.
///
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagCHOOSECOLORA~r1")]
[Flags]
public enum CC
{
/// Causes the dialog box to display all available colors in the set of basic colors.
CC_ANYCOLOR = 0x00000100,
///
/// Enables the hook procedure specified in the lpfnHook member of this structure. This flag is used only to initialize the
/// dialog box.
///
CC_ENABLEHOOK = 0x00000010,
///
/// The hInstance and lpTemplateName members specify a dialog box template to use in place of the default template. This flag is
/// used only to initialize the dialog box.
///
CC_ENABLETEMPLATE = 0x00000020,
///
/// The hInstance member identifies a data block that contains a preloaded dialog box template. The system ignores the
/// lpTemplateName member if this flag is specified. This flag is used only to initialize the dialog box.
///
CC_ENABLETEMPLATEHANDLE = 0x00000040,
///
/// Causes the dialog box to display the additional controls that allow the user to create custom colors. If this flag is not
/// set, the user must click the Define Custom Color button to display the custom color controls.
///
CC_FULLOPEN = 0x00000002,
/// Disables the Define Custom Color button.
CC_PREVENTFULLOPEN = 0x00000004,
/// Causes the dialog box to use the color specified in the rgbResult member as the initial color selection.
CC_RGBINIT = 0x00000001,
///
/// Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING
/// registered messages that the dialog box sends when the user clicks the Help button.
///
CC_SHOWHELP = 0x00000008,
/// Causes the dialog box to display only solid colors in the set of basic colors.
CC_SOLIDCOLOR = 0x00000080,
}
///
/// A set of bit flags that you can use to initialize the Font dialog box. When the dialog box returns, it sets these flags to
/// indicate the user input.
///
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagCHOOSEFONTA")]
[Flags]
public enum CF : uint
{
///
/// Causes the dialog box to display the Apply button. You should provide a hook procedure to process WM_COMMAND messages for
/// the Apply button. The hook procedure can send the WM_CHOOSEFONT_GETLOGFONT message to the dialog box to retrieve the address
/// of the structure that contains the current selections for the font.
///
CF_APPLY = 0x00000200,
///
/// This flag is obsolete. To limit font selections to all scripts except those that use the OEM or Symbol character sets, use
/// CF_SCRIPTSONLY. To get the original CF_ANSIONLY behavior, use CF_SELECTSCRIPT and specify ANSI_CHARSET in the lfCharSet
/// member of the LOGFONT structure pointed to by lpLogFont.
///
CF_ANSIONLY = 0x00000400,
///
/// This flag is ignored for font enumeration.
///
/// Windows Vista and Windows XP/2000: Causes the dialog box to list the available printer and screen fonts. The hDC member is a
/// handle to the device context or information context associated with the printer. This flag is a combination of the
/// CF_SCREENFONTS and CF_PRINTERFONTS flags.
///
///
CF_BOTH = 0x00000003,
///
/// Causes the dialog box to display the controls that allow the user to specify strikeout, underline, and text color options.
/// If this flag is set, you can use the rgbColors member to specify the initial text color. You can use the lfStrikeOut and
/// lfUnderline members of the structure pointed to by lpLogFont to specify the initial settings of the strikeout and underline
/// check boxes. ChooseFont can use these members to return the user's selections.
///
CF_EFFECTS = 0x00000100,
/// Enables the hook procedure specified in the lpfnHook member of this structure.
CF_ENABLEHOOK = 0x00000008,
///
/// Indicates that the hInstance and lpTemplateName members specify a dialog box template to use in place of the default template.
///
CF_ENABLETEMPLATE = 0x00000010,
///
/// Indicates that the hInstance member identifies a data block that contains a preloaded dialog box template. The system
/// ignores the lpTemplateName member if this flag is specified.
///
CF_ENABLETEMPLATEHANDLE = 0x00000020,
/// ChooseFont should enumerate and allow selection of only fixed-pitch fonts.
CF_FIXEDPITCHONLY = 0x00004000,
///
/// ChooseFont should indicate an error condition if the user attempts to select a font or style that is not listed in the
/// dialog box.
///
CF_FORCEFONTEXIST = 0x00010000,
///
/// ChooseFont should additionally display fonts that are set to Hide in Fonts Control Panel.
/// Windows Vista and Windows XP/2000: This flag is not supported until Windows 7.
///
CF_INACTIVEFONTS = 0x02000000,
/// ChooseFont should use the structure pointed to by the lpLogFont member to initialize the dialog box controls.
CF_INITTOLOGFONTSTRUCT = 0x00000040,
/// ChooseFont should select only font sizes within the range specified by the nSizeMin and nSizeMax members.
CF_LIMITSIZE = 0x00002000,
/// Same as the CF_NOVECTORFONTS flag.
CF_NOOEMFONTS = 0x00000800,
///
/// When using a LOGFONT structure to initialize the dialog box controls, use this flag to prevent the dialog box from
/// displaying an initial selection for the font name combo box. This is useful when there is no single font name that applies
/// to the text selection.
///
CF_NOFACESEL = 0x00080000,
///
/// Disables the Script combo box. When this flag is set, the lfCharSet member of the LOGFONT structure is set to
/// DEFAULT_CHARSET when ChooseFont returns. This flag is used only to initialize the dialog box.
///
CF_NOSCRIPTSEL = 0x00800000,
/// ChooseFont should not display or allow selection of font simulations.
CF_NOSIMULATIONS = 0x00001000,
///
/// When using a structure to initialize the dialog box controls, use this flag to prevent the dialog box from displaying an
/// initial selection for the Font Size combo box. This is useful when there is no single font size that applies to the text selection.
///
CF_NOSIZESEL = 0x00200000,
///
/// When using a LOGFONT structure to initialize the dialog box controls, use this flag to prevent the dialog box from
/// displaying an initial selection for the Font Style combo box. This is useful when there is no single font style that applies
/// to the text selection.
///
CF_NOSTYLESEL = 0x00100000,
/// ChooseFont should not allow vector font selections.
CF_NOVECTORFONTS = 0x00000800,
/// Causes the Font dialog box to list only horizontally oriented fonts.
CF_NOVERTFONTS = 0x01000000,
///
/// This flag is ignored for font enumeration.
///
/// Windows Vista and Windows XP/2000: Causes the dialog box to list only the fonts supported by the printer associated with the
/// device context or information context identified by the hDC member. It also causes the font type description label to appear
/// at the bottom of the Font dialog box.
///
///
CF_PRINTERFONTS = 0x00000002,
///
/// Specifies that ChooseFont should allow only the selection of scalable fonts. Scalable fonts include vector fonts, scalable
/// printer fonts, TrueType fonts, and fonts scaled by other technologies.
///
CF_SCALABLEONLY = 0x00020000,
///
/// This flag is ignored for font enumeration.
/// Windows Vista and Windows XP/2000: Causes the dialog box to list only the screen fonts supported by the system.
///
CF_SCREENFONTS = 0x00000001,
///
/// ChooseFont should allow selection of fonts for all non-OEM and Symbol character sets, as well as the ANSI character set.
/// This supersedes the CF_ANSIONLY value.
///
CF_SCRIPTSONLY = 0x00000400,
///
/// When specified on input, only fonts with the character set identified in the lfCharSet member of the LOGFONT structure are
/// displayed. The user will not be allowed to change the character set specified in the Scripts combo box.
///
CF_SELECTSCRIPT = 0x00400000,
///
/// Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING
/// registered messages that the dialog box sends when the user clicks the Help button.
///
CF_SHOWHELP = 0x00000004,
/// ChooseFont should only enumerate and allow the selection of TrueType fonts.
CF_TTONLY = 0x00040000,
///
/// The lpszStyle member is a pointer to a buffer that contains style data that ChooseFont should use to initialize the Font
/// Style combo box. When the user closes the dialog box, ChooseFont copies style data for the user's selection to this buffer.
///
/// Note To globalize your application, you should specify the style by using the lfWeight and lfItalic members of the LOGFONT
/// structure pointed to by lpLogFont. The style name may change depending on the system user interface language.
///
///
CF_USESTYLE = 0x00000080,
///
/// Obsolete. ChooseFont ignores this flag.
///
/// Windows Vista and Windows XP/2000: ChooseFont should allow only the selection of fonts available on both the printer and the
/// display. If this flag is specified, the CF_SCREENSHOTS and CF_PRINTERFONTS, or CF_BOTH flags should also be specified.
///
///
CF_WYSIWYG = 0x00008000,
}
/// Indicates whether the strings contained in the DEVNAMES structure identify the default printer.
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagDEVNAMES")]
[Flags]
public enum DN : ushort
{
///
/// The DN_DEFAULTPRN flag is used if the default printer was selected. If a specific printer is selected, the flag is not used.
///
DN_DEFAULTPRN = 1
}
///
/// A set of bit flags that you can use to initialize the dialog box. The dialog box sets these flags when it sends the
/// FINDMSGSTRING registered message to indicate the user's input.
///
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagFINDREPLACEA")]
[Flags]
public enum FR : uint
{
///
/// If set in a FINDMSGSTRING message, indicates that the dialog box is closing. When you receive a message with this flag set,
/// the dialog box handle returned by the FindText or ReplaceText function is no longer valid.
///
FR_DIALOGTERM = 0x00000040,
///
/// If set, the Down button of the direction radio buttons in a Find dialog box is selected indicating that you should search
/// from the current location to the end of the document. If not set, the Up button is selected so you should search to the
/// beginning of the document. You can set this flag to initialize the dialog box. If set in a FINDMSGSTRING message, indicates
/// the user's selection.
///
FR_DOWN = 0x00000001,
///
/// Enables the hook function specified in the lpfnHook member. This flag is used only to initialize the dialog box.
///
FR_ENABLEHOOK = 0x00000100,
///
/// Indicates that the hInstance and lpTemplateName members specify a dialog box template to use in place of the default
/// template. This flag is used only to initialize the dialog box.
///
FR_ENABLETEMPLATE = 0x00000200,
///
/// Indicates that the hInstance member identifies a data block that contains a preloaded dialog box template. The system
/// ignores the lpTemplateName member if this flag is specified.
///
FR_ENABLETEMPLATEHANDLE = 0x00002000,
///
/// If set in a FINDMSGSTRING message, indicates that the user clicked the Find Next button in a Find or Replace dialog box. The
/// lpstrFindWhat member specifies the string to search for.
///
FR_FINDNEXT = 0x00000008,
/// If set when initializing a Find dialog box, hides the search direction radio buttons.
FR_HIDEUPDOWN = 0x00004000,
/// If set when initializing a Find or Replace dialog box, hides the Match Case check box.
FR_HIDEMATCHCASE = 0x00008000,
/// If set when initializing a Find or Replace dialog box, hides the Match Whole Word Only check box.
FR_HIDEWHOLEWORD = 0x00010000,
///
/// If set, the Match Case check box is selected indicating that the search should be case-sensitive. If not set, the check box
/// is unselected so the search should be case-insensitive. You can set this flag to initialize the dialog box. If set in a
/// FINDMSGSTRING message, indicates the user's selection.
///
FR_MATCHCASE = 0x00000004,
/// If set when initializing a Find or Replace dialog box, disables the Match Case check box.
FR_NOMATCHCASE = 0x00000800,
/// If set when initializing a Find dialog box, disables the search direction radio buttons.
FR_NOUPDOWN = 0x00000400,
/// If set when initializing a Find or Replace dialog box, disables the Whole Word check box.
FR_NOWHOLEWORD = 0x00001000,
///
/// If set in a FINDMSGSTRING message, indicates that the user clicked the Replace button in a Replace dialog box. The
/// lpstrFindWhat member specifies the string to be replaced and the lpstrReplaceWith member specifies the replacement string.
///
FR_REPLACE = 0x00000010,
///
/// If set in a FINDMSGSTRING message, indicates that the user clicked the Replace All button in a Replace dialog box. The
/// lpstrFindWhat member specifies the string to be replaced and the lpstrReplaceWith member specifies the replacement string.
///
FR_REPLACEALL = 0x00000020,
///
/// Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING
/// registered messages that the dialog box sends when the user clicks the Help button.
///
FR_SHOWHELP = 0x00000080,
///
/// If set, the Match Whole Word Only check box is selected indicating that you should search only for whole words that match
/// the search string. If not set, the check box is unselected so you should also search for word fragments that match the
/// search string. You can set this flag to initialize the dialog box. If set in a FINDMSGSTRING message, indicates the user's selection.
///
FR_WHOLEWORD = 0x00000002,
///
FR_RAW = 0x00020000,
///
FR_SHOWWRAPAROUND = 0x00040000,
///
FR_NOWRAPAROUND = 0x00080000,
///
FR_WRAPAROUND = 0x00100000,
///
FR_MATCHDIAC = 0x20000000,
///
FR_MATCHKASHIDA = 0x40000000,
///
FR_MATCHALEFHAMZA = 0x80000000,
}
///
/// A set of bit flags you can use to initialize the dialog box. When the dialog box returns, it sets these flags to indicate the
/// user's input.
///
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagOFNA")]
[Flags]
public enum OFN
{
///
/// The File Name list box allows multiple selections. If you also set the OFN_EXPLORER flag, the dialog box uses the
/// Explorer-style user interface; otherwise, it uses the old-style user interface.
///
/// If the user selects more than one file, the lpstrFile buffer returns the path to the current directory followed by the file
/// names of the selected files. The nFileOffset member is the offset, in bytes or characters, to the first file name, and the
/// nFileExtension member is not used. For Explorer-style dialog boxes, the directory and file name strings are NULL separated,
/// with an extra NULL character after the last file name. This format enables the Explorer-style dialog boxes to return long
/// file names that include spaces. For old-style dialog boxes, the directory and file name strings are separated by spaces and
/// the function uses short file names for file names with spaces. You can use the FindFirstFile function to convert between
/// long and short file names.
///
///
/// If you specify a custom template for an old-style dialog box, the definition of the File Name list box must contain the
/// LBS_EXTENDEDSEL value.
///
///
OFN_ALLOWMULTISELECT = 0x00000200,
///
/// If the user specifies a file that does not exist, this flag causes the dialog box to prompt the user for permission to
/// create the file. If the user chooses to create the file, the dialog box closes and the function returns the specified name;
/// otherwise, the dialog box remains open. If you use this flag with the OFN_ALLOWMULTISELECT flag, the dialog box allows the
/// user to specify only one nonexistent file.
///
OFN_CREATEPROMPT = 0x00002000,
///
/// Prevents the system from adding a link to the selected file in the file system directory that contains the user's most
/// recently used documents. To retrieve the location of this directory, call the SHGetSpecialFolderLocation function with the
/// CSIDL_RECENT flag.
///
OFN_DONTADDTORECENT = 0x02000000,
/// Enables the hook function specified in the lpfnHook member.
OFN_ENABLEHOOK = 0x00000020,
///
/// Causes the dialog box to send CDN_INCLUDEITEM notification messages to your OFNHookProc hook procedure when the user opens a
/// folder. The dialog box sends a notification for each item in the newly opened folder. These messages enable you to control
/// which items the dialog box displays in the folder's item list.
///
OFN_ENABLEINCLUDENOTIFY = 0x00400000,
///
/// Enables the Explorer-style dialog box to be resized using either the mouse or the keyboard. By default, the Explorer-style
/// Open and Save As dialog boxes allow the dialog box to be resized regardless of whether this flag is set. This flag is
/// necessary only if you provide a hook procedure or custom template. The old-style dialog box does not permit resizing.
///
OFN_ENABLESIZING = 0x00800000,
///
/// The lpTemplateName member is a pointer to the name of a dialog template resource in the module identified by the hInstance
/// member. If the OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of
/// the default Explorer-style dialog box. If the OFN_EXPLORER flag is not set, the system uses the template to create an
/// old-style dialog box that replaces the default dialog box.
///
OFN_ENABLETEMPLATE = 0x00000040,
///
/// The hInstance member identifies a data block that contains a preloaded dialog box template. The system ignores
/// lpTemplateName if this flag is specified. If the OFN_EXPLORER flag is set, the system uses the specified template to create
/// a dialog box that is a child of the default Explorer-style dialog box. If the OFN_EXPLORER flag is not set, the system uses
/// the template to create an old-style dialog box that replaces the default dialog box.
///
OFN_ENABLETEMPLATEHANDLE = 0x00000080,
///
/// Indicates that any customizations made to the Open or Save As dialog box use the Explorer-style customization methods. For
/// more information, see Explorer-Style Hook Procedures and Explorer-Style Custom Templates.
///
/// By default, the Open and Save As dialog boxes use the Explorer-style user interface regardless of whether this flag is set.
/// This flag is necessary only if you provide a hook procedure or custom template, or set the OFN_ALLOWMULTISELECT flag.
///
///
/// If you want the old-style user interface, omit the OFN_EXPLORER flag and provide a replacement old-style template or hook
/// procedure. If you want the old style but do not need a custom template or hook procedure, simply provide a hook procedure
/// that always returns FALSE.
///
///
OFN_EXPLORER = 0x00080000,
///
/// The user typed a file name extension that differs from the extension specified by lpstrDefExt. The function does not use
/// this flag if lpstrDefExt is NULL.
///
OFN_EXTENSIONDIFFERENT = 0x00000400,
///
/// The user can type only names of existing files in the File Name entry field. If this flag is specified and the user enters
/// an invalid name, the dialog box procedure displays a warning in a message box. If this flag is specified, the
/// OFN_PATHMUSTEXIST flag is also used. This flag can be used in an Open dialog box. It cannot be used with a Save As dialog box.
///
OFN_FILEMUSTEXIST = 0x00001000,
///
/// Forces the showing of system and hidden files, thus overriding the user setting to show or not show hidden files. However, a
/// file that is marked both system and hidden is not shown.
///
OFN_FORCESHOWHIDDEN = 0x10000000,
/// Hides the Read Only check box.
OFN_HIDEREADONLY = 0x00000004,
///
/// For old-style dialog boxes, this flag causes the dialog box to use long file names. If this flag is not specified, or if the
/// OFN_ALLOWMULTISELECT flag is also set, old-style dialog boxes use short file names (8.3 format) for file names with spaces.
/// Explorer-style dialog boxes ignore this flag and always display long file names.
///
OFN_LONGNAMES = 0x00200000,
///
/// Restores the current directory to its original value if the user changed the directory while searching for files.
/// This flag is ineffective for GetOpenFileName.
///
OFN_NOCHANGEDIR = 0x00000008,
///
/// Directs the dialog box to return the path and file name of the selected shortcut (.LNK) file. If this value is not
/// specified, the dialog box returns the path and file name of the file referenced by the shortcut.
///
OFN_NODEREFERENCELINKS = 0x00100000,
///
/// For old-style dialog boxes, this flag causes the dialog box to use short file names (8.3 format). Explorer-style dialog
/// boxes ignore this flag and always display long file names.
///
OFN_NOLONGNAMES = 0x00040000,
/// Hides and disables the Network button.
OFN_NONETWORKBUTTON = 0x00020000,
/// The returned file does not have the Read Only check box selected and is not in a write-protected directory.
OFN_NOREADONLYRETURN = 0x00008000,
///
/// The file is not created before the dialog box is closed. This flag should be specified if the application saves the file on
/// a create-nonmodify network share. When an application specifies this flag, the library does not check for write protection,
/// a full disk, an open drive door, or network protection. Applications using this flag must perform file operations carefully,
/// because a file cannot be reopened once it is closed.
///
OFN_NOTESTFILECREATE = 0x00010000,
///
/// The common dialog boxes allow invalid characters in the returned file name. Typically, the calling application uses a hook
/// procedure that checks the file name by using the FILEOKSTRING message. If the text box in the edit control is empty or
/// contains nothing but spaces, the lists of files and directories are updated. If the text box in the edit control contains
/// anything else, nFileOffset and nFileExtension are set to values generated by parsing the text. No default extension is added
/// to the text, nor is text copied to the buffer specified by lpstrFileTitle. If the value specified by nFileOffset is less
/// than zero, the file name is invalid. Otherwise, the file name is valid, and nFileExtension and nFileOffset can be used as if
/// the OFN_NOVALIDATE flag had not been specified.
///
OFN_NOVALIDATE = 0x00000100,
///
/// Causes the Save As dialog box to generate a message box if the selected file already exists. The user must confirm whether
/// to overwrite the file.
///
OFN_OVERWRITEPROMPT = 0x00000002,
///
/// The user can type only valid paths and file names. If this flag is used and the user types an invalid path and file name in
/// the File Name entry field, the dialog box function displays a warning in a message box.
///
OFN_PATHMUSTEXIST = 0x00000800,
///
/// Causes the Read Only check box to be selected initially when the dialog box is created. This flag indicates the state of the
/// Read Only check box when the dialog box is closed.
///
OFN_READONLY = 0x00000001,
///
/// Specifies that if a call to the OpenFile function fails because of a network sharing violation, the error is ignored and the
/// dialog box returns the selected file name. If this flag is not set, the dialog box notifies your hook procedure when a
/// network sharing violation occurs for the file name specified by the user. If you set the OFN_EXPLORER flag, the dialog box
/// sends the CDN_SHAREVIOLATION message to the hook procedure. If you do not set OFN_EXPLORER, the dialog box sends the
/// SHAREVISTRING registered message to the hook procedure.
///
OFN_SHAREAWARE = 0x00004000,
///
/// Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING
/// registered messages that the dialog box sends when the user clicks the Help button. An Explorer-style dialog box sends a
/// CDN_HELP notification message to your hook procedure when the user clicks the Help button.
///
OFN_SHOWHELP = 0x00000010,
}
/// A set of bit flags you can use to initialize the dialog box.
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagOFNA")]
[Flags]
public enum OFN_EX
{
///
/// If this flag is set, the places bar is not displayed. If this flag is not set, Explorer-style dialog boxes include a places
/// bar containing icons for commonly-used folders, such as Favorites and Desktop.
///
OFN_EX_NOPLACESBAR = 0x00000001,
}
/// Initializes the Print dialog box. When the dialog box returns, it sets these flags to indicate the user's input.
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagPDA")]
[Flags]
public enum PD
{
///
/// The default flag that indicates that the All radio button is initially selected. This flag is used as a placeholder to
/// indicate that the PD_PAGENUMS and PD_SELECTION flags are not specified.
///
PD_ALLPAGES = 0x00000000,
///
/// If this flag is set, the Collate check box is selected.
///
/// If this flag is set when the PrintDlg function returns, the application must simulate collation of multiple copies. For more
/// information, see the description of the PD_USEDEVMODECOPIESANDCOLLATE flag.
///
/// See PD_NOPAGENUMS.
///
PD_COLLATE = 0x00000010,
/// Disables the Print to File check box.
PD_DISABLEPRINTTOFILE = 0x00080000,
///
/// Enables the hook procedure specified in the lpfnPrintHook member. This enables the hook procedure for the Print dialog box.
///
PD_ENABLEPRINTHOOK = 0x00001000,
///
/// Indicates that the hInstance and lpPrintTemplateName members specify a replacement for the default Print dialog box template.
///
PD_ENABLEPRINTTEMPLATE = 0x00004000,
///
/// Indicates that the hPrintTemplate member identifies a data block that contains a preloaded dialog box template. This
/// template replaces the default template for the Print dialog box. The system ignores the lpPrintTemplateName member if this
/// flag is specified.
///
PD_ENABLEPRINTTEMPLATEHANDLE = 0x00010000,
///
/// Enables the hook procedure specified in the lpfnSetupHook member. This enables the hook procedure for the Print Setup dialog box.
///
PD_ENABLESETUPHOOK = 0x00002000,
///
/// Indicates that the hInstance and lpSetupTemplateName members specify a replacement for the default Print Setup dialog box template.
///
PD_ENABLESETUPTEMPLATE = 0x00008000,
///
/// Indicates that the hSetupTemplate member identifies a data block that contains a preloaded dialog box template. This
/// template replaces the default template for the Print Setup dialog box. The system ignores the lpSetupTemplateName member if
/// this flag is specified.
///
PD_ENABLESETUPTEMPLATEHANDLE = 0x00020000,
/// Hides the Print to File check box.
PD_HIDEPRINTTOFILE = 0x00100000,
/// Hides and disables the Network button.
PD_NONETWORKBUTTON = 0x00200000,
///
/// Disables the Pages radio button and the associated edit controls. Also, it causes the Collate check box to appear in the dialog.
///
PD_NOPAGENUMS = 0x00000008,
/// Disables the Selection radio button.
PD_NOSELECTION = 0x00000004,
/// Prevents the warning message from being displayed when there is no default printer.
PD_NOWARNING = 0x00000080,
///
/// If this flag is set, the Pages radio button is selected. If this flag is set when the PrintDlg function returns, the
/// nFromPage and nToPage members indicate the starting and ending pages specified by the user.
///
PD_PAGENUMS = 0x00000002,
/// Causes the system to display the Print Setup dialog box rather than the Print dialog box.
PD_PRINTSETUP = 0x00000040,
///
/// If this flag is set, the Print to File check box is selected. If this flag is set when the PrintDlg function returns, the
/// offset indicated by the wOutputOffset member of the DEVNAMES structure contains the string "FILE:". When you call the
/// StartDoc function to start the printing operation, specify this "FILE:" string in the lpszOutput member of the DOCINFO
/// structure. Specifying this string causes the print subsystem to query the user for the name of the output file.
///
PD_PRINTTOFILE = 0x00000020,
///
/// Causes PrintDlg to return a device context matching the selections the user made in the dialog box. The device context is
/// returned in hDC.
///
PD_RETURNDC = 0x00000100,
///
/// If this flag is set, the PrintDlg function does not display the dialog box. Instead, it sets the hDevNames and hDevMode
/// members to handles to DEVMODE and DEVNAMES structures that are initialized for the system default printer. Both hDevNames
/// and hDevMode must be NULL, or PrintDlg returns an error.
///
PD_RETURNDEFAULT = 0x00000400,
///
/// Similar to the PD_RETURNDC flag, except this flag returns an information context rather than a device context. If neither
/// PD_RETURNDC nor PD_RETURNIC is specified, hDC is undefined on output.
///
PD_RETURNIC = 0x00000200,
///
/// If this flag is set, the Selection radio button is selected. If neither PD_PAGENUMS nor PD_SELECTION is set, the All radio
/// button is selected.
///
PD_SELECTION = 0x00000001,
///
/// Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING
/// registered messages that the dialog box sends when the user clicks the Help button.
///
PD_SHOWHELP = 0x00000800,
/// Same as PD_USEDEVMODECOPIESANDCOLLATE.
PD_USEDEVMODECOPIES = 0x00040000,
///
/// This flag indicates whether your application supports multiple copies and collation. Set this flag on input to indicate that
/// your application does not support multiple copies and collation. In this case, the nCopies member of the PRINTDLG structure
/// always returns 1, and PD_COLLATE is never set in the Flags member.
///
/// If this flag is not set, the application is responsible for printing and collating multiple copies. In this case, the
/// nCopies member of the PRINTDLG structure indicates the number of copies the user wants to print, and the PD_COLLATE flag in
/// the Flags member indicates whether the user wants collation.
///
///
/// Regardless of whether this flag is set, an application can determine from nCopies and PD_COLLATE how many copies to render
/// and whether to print them collated.
///
///
/// If this flag is set and the printer driver does not support multiple copies, the Copies edit control is disabled. Similarly,
/// if this flag is set and the printer driver does not support collation, the Collate check box is disabled.
///
///
/// The dmCopies and dmCollate members of the DEVMODE structure contain the copies and collate information used by the printer
/// driver. If this flag is set and the printer driver supports multiple copies, the dmCopies member indicates the number of
/// copies requested by the user. If this flag is set and the printer driver supports collation, the dmCollate member of the
/// DEVMODE structure indicates whether the user wants collation. If this flag is not set, the dmCopies member always returns 1,
/// and the dmCollate member is always zero.
///
///
/// Known issue on Windows 2000/XP/2003: If this flag is not set before calling PrintDlg, PrintDlg might swap nCopies and
/// dmCopies values when it returns. The workaround for this issue is use dmCopies if its value is larger than 1, else, use
/// nCopies, for you to to get the actual number of copies to be printed when PrintDlg returns.
///
///
PD_USEDEVMODECOPIESANDCOLLATE = 0x00040000,
///
PD_CURRENTPAGE = 0x00400000,
///
PD_NOCURRENTPAGE = 0x00800000,
///
PD_EXCLUSIONFLAGS = 0x01000000,
///
PD_USELARGETEMPLATE = 0x10000000,
}
///
/// A set of bit flags that can exclude items from the printer driver property pages in the Print property sheet. This value is used
/// only if the PD_EXCLUSIONFLAGS flag is set in the Flags member. Exclusion flags should be used only if the item to be excluded
/// will be included on either the General page or on an application-defined page in the Print property sheet.
///
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagPDEXA")]
public enum PD_EXCL : uint
{
///
/// Excludes the Copies and Collate controls from the printer driver property pages in a Print property sheet. This flag should
/// always be set when the application uses the default Copies and Collate controls provided by the lower portion of the General
/// page of the Print property sheet.
///
PD_EXCL_COPIESANDCOLLATE = DMFIELDS.DM_COPIES | DMFIELDS.DM_COLLATE
}
///
/// On input, set this member to zero. If the PrintDlgEx function returns S_OK, dwResultAction contains the outcome of the dialog.
/// If PrintDlgEx returns an error, this member should be ignored.
///
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagPDEXA")]
public enum PD_RESULT
{
/// The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged.
PD_RESULT_CANCEL = 0,
/// The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user.
PD_RESULT_PRINT = 1,
///
/// The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to apply the
/// changes made in the property sheet, but does not want to print yet. The PRINTDLGEX structure contains the information
/// specified by the user at the time the Apply button was clicked.
///
PD_RESULT_APPLY = 2
}
///
/// A set of bit flags that you can use to initialize the Page Setup dialog box. When the dialog box returns, it sets these flags to
/// indicate the user's input.
///
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagPSDA")]
[Flags]
public enum PSD
{
///
/// Sets the minimum values that the user can specify for the page margins to be the minimum margins allowed by the printer.
/// This is the default. This flag is ignored if the PSD_MARGINS and PSD_MINMARGINS flags are also specified.
///
PSD_DEFAULTMINMARGINS = 0x00000000,
/// Disables the margin controls, preventing the user from setting the margins.
PSD_DISABLEMARGINS = 0x00000010,
/// Disables the orientation controls, preventing the user from setting the page orientation.
PSD_DISABLEORIENTATION = 0x00000100,
///
/// Prevents the dialog box from drawing the contents of the sample page. If you enable a PagePaintHook hook procedure, you can
/// still draw the contents of the sample page.
///
PSD_DISABLEPAGEPAINTING = 0x00080000,
/// Disables the paper controls, preventing the user from setting page parameters such as the paper size and source.
PSD_DISABLEPAPER = 0x00000200,
///
/// Obsolete.
///
/// Windows XP/2000: Disables the Printer button, preventing the user from invoking a dialog box that contains additional
/// printer setup information.
///
///
PSD_DISABLEPRINTER = 0x00000020,
/// Enables the hook procedure specified in the lpfnPagePaintHook member.
PSD_ENABLEPAGEPAINTHOOK = 0x00040000,
/// Enables the hook procedure specified in the lpfnPageSetupHook member.
PSD_ENABLEPAGESETUPHOOK = 0x00002000,
///
/// Indicates that the hInstance and lpPageSetupTemplateName members specify a dialog box template to use in place of the
/// default template.
///
PSD_ENABLEPAGESETUPTEMPLATE = 0x00008000,
///
/// Indicates that the hPageSetupTemplate member identifies a data block that contains a preloaded dialog box template. The
/// system ignores the lpPageSetupTemplateName member if this flag is specified.
///
PSD_ENABLEPAGESETUPTEMPLATEHANDLE = 0x00020000,
///
/// Indicates that hundredths of millimeters are the unit of measurement for margins and paper size. The values in the rtMargin,
/// rtMinMargin, and ptPaperSize members are in hundredths of millimeters. You can set this flag on input to override the
/// default unit of measurement for the user's locale. When the function returns, the dialog box sets this flag to indicate the
/// units used.
///
PSD_INHUNDREDTHSOFMILLIMETERS = 0x00000008,
///
/// Indicates that thousandths of inches are the unit of measurement for margins and paper size. The values in the rtMargin,
/// rtMinMargin, and ptPaperSize members are in thousandths of inches. You can set this flag on input to override the default
/// unit of measurement for the user's locale. When the function returns, the dialog box sets this flag to indicate the units used.
///
PSD_INTHOUSANDTHSOFINCHES = 0x00000004,
/// Reserved.
PSD_INWININIINTLMEASURE = 0x00000000,
///
/// Causes the system to use the values specified in the rtMargin member as the initial widths for the left, top, right, and
/// bottom margins. If PSD_MARGINS is not set, the system sets the initial widths to one inch for all margins.
///
PSD_MARGINS = 0x00000002,
///
/// Causes the system to use the values specified in the rtMinMargin member as the minimum allowable widths for the left, top,
/// right, and bottom margins. The system prevents the user from entering a width that is less than the specified minimum. If
/// PSD_MINMARGINS is not specified, the system sets the minimum allowable widths to those allowed by the printer.
///
PSD_MINMARGINS = 0x00000001,
/// Hides and disables the Network button.
PSD_NONETWORKBUTTON = 0x00200000,
/// Prevents the system from displaying a warning message when there is no default printer.
PSD_NOWARNING = 0x00000080,
///
/// PageSetupDlg does not display the dialog box. Instead, it sets the hDevNames and hDevMode members to handles to DEVMODE and
/// DEVNAMES structures that are initialized for the system default printer. PageSetupDlg returns an error if either hDevNames
/// or hDevMode is not NULL.
///
PSD_RETURNDEFAULT = 0x00000400,
///
/// Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING
/// registered messages that the dialog box sends when the user clicks the Help button.
///
PSD_SHOWHELP = 0x00000800,
}
///
/// Contains information the ChooseColor function uses to initialize the Color dialog box. After the user closes the dialog
/// box, the system returns information about the user's selection in this structure.
///
// https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-choosecolora-r1 typedef struct tagCHOOSECOLORA { DWORD
// lStructSize; HWND hwndOwner; HWND hInstance; COLORREF rgbResult; COLORREF *lpCustColors; DWORD Flags; LPARAM lCustData;
// LPCCHOOKPROC lpfnHook; LPCSTR lpTemplateName; LPEDITMENU lpEditInfo; } CHOOSECOLORA, *LPCHOOSECOLORA;
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagCHOOSECOLORA~r1")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct CHOOSECOLOR
{
///
/// Type: DWORD
/// The length, in bytes, of the structure.
///
public uint lStructSize;
///
/// Type: HWND
///
/// A handle to the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the
/// dialog box has no owner.
///
///
public HWND hwndOwner;
///
/// Type: HWND
///
/// If the CC_ENABLETEMPLATEHANDLE flag is set in the Flags member, hInstance is a handle to a memory
/// object containing a dialog box template. If the CC_ENABLETEMPLATE flag is set, hInstance is a handle to a
/// module that contains a dialog box template named by the lpTemplateName member. If neither
/// CC_ENABLETEMPLATEHANDLE nor CC_ENABLETEMPLATE is set, this member is ignored.
///
///
public HWND hInstance;
///
/// Type: COLORREF
///
/// If the CC_RGBINIT flag is set, rgbResult specifies the color initially selected when the dialog box is
/// created. If the specified color value is not among the available colors, the system selects the nearest solid color
/// available. If rgbResult is zero or CC_RGBINIT is not set, the initially selected color is black. If the user
/// clicks the OK button, rgbResult specifies the user's color selection. To create a COLORREF color value, use
/// the RGB macro.
///
///
public COLORREF rgbResult;
///
/// Type: COLORREF*
///
/// A pointer to an array of 16 values that contain red, green, blue (RGB) values for the custom color boxes in the dialog box.
/// If the user modifies these colors, the system updates the array with the new RGB values. To preserve new custom colors
/// between calls to the ChooseColor function, you should allocate static memory for the array. To create a COLORREF color
/// value, use the RGB macro.
///
///
public IntPtr lpCustColors;
///
/// Type: DWORD
///
/// A set of bit flags that you can use to initialize the Color dialog box. When the dialog box returns, it sets these
/// flags to indicate the user's input. This member can be a combination of the following flags.
///
///
///
/// Value
/// Meaning
///
/// -
/// CC_ANYCOLOR 0x00000100
/// Causes the dialog box to display all available colors in the set of basic colors.
///
/// -
/// CC_ENABLEHOOK 0x00000010
///
/// Enables the hook procedure specified in the lpfnHook member of this structure. This flag is used only to initialize the
/// dialog box.
///
///
/// -
/// CC_ENABLETEMPLATE 0x00000020
///
/// The hInstance and lpTemplateName members specify a dialog box template to use in place of the default template. This flag is
/// used only to initialize the dialog box.
///
///
/// -
/// CC_ENABLETEMPLATEHANDLE 0x00000040
///
/// The hInstance member identifies a data block that contains a preloaded dialog box template. The system ignores the
/// lpTemplateName member if this flag is specified. This flag is used only to initialize the dialog box.
///
///
/// -
/// CC_FULLOPEN 0x00000002
///
/// Causes the dialog box to display the additional controls that allow the user to create custom colors. If this flag is not
/// set, the user must click the Define Custom Color button to display the custom color controls.
///
///
/// -
/// CC_PREVENTFULLOPEN 0x00000004
/// Disables the Define Custom Color button.
///
/// -
/// CC_RGBINIT 0x00000001
/// Causes the dialog box to use the color specified in the rgbResult member as the initial color selection.
///
/// -
/// CC_SHOWHELP 0x00000008
///
/// Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING
/// registered messages that the dialog box sends when the user clicks the Help button.
///
///
/// -
/// CC_SOLIDCOLOR 0x00000080
/// Causes the dialog box to display only solid colors in the set of basic colors.
///
///
///
public CC Flags;
///
/// Type: LPARAM
///
/// Application-defined data that the system passes to the hook procedure identified by the lpfnHook member. When the
/// system sends the WM_INITDIALOG message to the hook procedure, the message's lParam parameter is a pointer to the
/// CHOOSECOLOR structure specified when the dialog was created. The hook procedure can use this pointer to get the
/// lCustData value.
///
///
public IntPtr lCustData;
///
/// Type: LPCCHOOKPROC
///
/// A pointer to a CCHookProc hook procedure that can process messages intended for the dialog box. This member is ignored
/// unless the CC_ENABLEHOOK flag is set in the Flags member.
///
///
public LPCCHOOKPROC lpfnHook;
///
/// Type: LPCTSTR
///
/// The name of the dialog box template resource in the module identified by the hInstance member. This template is
/// substituted for the standard dialog box template. For numbered dialog box resources, lpTemplateName can be a value
/// returned by the MAKEINTRESOURCE macro. This member is ignored unless the CC_ENABLETEMPLATE flag is set in the
/// Flags member.
///
///
[MarshalAs(UnmanagedType.LPTStr)]
public string lpTemplateName;
}
///
/// Contains information that the ChooseFont function uses to initialize the Font dialog box. After the user closes the
/// dialog box, the system returns information about the user's selection in this structure.
///
// https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-choosefonta typedef struct tagCHOOSEFONTA { DWORD
// lStructSize; HWND hwndOwner; HDC hDC; LPLOGFONTA lpLogFont; INT iPointSize; DWORD Flags; COLORREF rgbColors; LPARAM lCustData;
// LPCFHOOKPROC lpfnHook; LPCSTR lpTemplateName; HINSTANCE hInstance; LPSTR lpszStyle; WORD nFontType; WORD ___MISSING_ALIGNMENT__;
// INT nSizeMin; INT nSizeMax; } CHOOSEFONTA;
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagCHOOSEFONTA")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct CHOOSEFONT
{
///
/// Type: DWORD
/// The length of the structure, in bytes.
///
public uint lStructSize;
///
/// Type: HWND
///
/// A handle to the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the
/// dialog box has no owner.
///
///
public HWND hwndOwner;
///
/// Type: HDC
/// This member is ignored by the ChooseFont function.
///
/// Windows Vista and Windows XP/2000: A handle to the device context or information context of the printer whose fonts
/// will be listed in the dialog box. This member is used only if the Flags member specifies the CF_PRINTERFONTS
/// or CF_BOTH flag; otherwise, this member is ignored.
///
///
public HDC hDC;
///
/// Type: *
///
/// A pointer to a LOGFONT structure. If you set the CF_INITTOLOGFONTSTRUCT flag in the Flags member and
/// initialize the other members, the ChooseFont function initializes the dialog box with a font that matches the LOGFONT
/// members. If the user clicks the OK button, ChooseFont sets the members of the LOGFONT structure based
/// on the user's selections.
///
///
public IntPtr lpLogFont;
///
/// Type: INT
///
/// The size of the selected font, in units of 1/10 of a point. The ChooseFont function sets this value after the user closes
/// the dialog box.
///
///
public int iPointSize;
///
/// Type: DWORD
///
/// A set of bit flags that you can use to initialize the Font dialog box. When the dialog box returns, it sets these
/// flags to indicate the user input. This member can be one or more of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// CF_APPLY 0x00000200L
///
/// Causes the dialog box to display the Apply button. You should provide a hook procedure to process WM_COMMAND messages for
/// the Apply button. The hook procedure can send the WM_CHOOSEFONT_GETLOGFONT message to the dialog box to retrieve the address
/// of the structure that contains the current selections for the font.
///
///
/// -
/// CF_ANSIONLY 0x00000400L
///
/// This flag is obsolete. To limit font selections to all scripts except those that use the OEM or Symbol character sets, use
/// CF_SCRIPTSONLY. To get the original CF_ANSIONLY behavior, use CF_SELECTSCRIPT and specify ANSI_CHARSET in the lfCharSet
/// member of the LOGFONT structure pointed to by lpLogFont.
///
///
/// -
/// CF_BOTH 0x00000003
///
/// This flag is ignored for font enumeration. Windows Vista and Windows XP/2000: Causes the dialog box to list the available
/// printer and screen fonts. The hDC member is a handle to the device context or information context associated with the
/// printer. This flag is a combination of the CF_SCREENFONTS and CF_PRINTERFONTS flags.
///
///
/// -
/// CF_EFFECTS 0x00000100L
///
/// Causes the dialog box to display the controls that allow the user to specify strikeout, underline, and text color options.
/// If this flag is set, you can use the rgbColors member to specify the initial text color. You can use the lfStrikeOut and
/// lfUnderline members of the structure pointed to by lpLogFont to specify the initial settings of the strikeout and underline
/// check boxes. ChooseFont can use these members to return the user's selections.
///
///
/// -
/// CF_ENABLEHOOK 0x00000008L
/// Enables the hook procedure specified in the lpfnHook member of this structure.
///
/// -
/// CF_ENABLETEMPLATE 0x00000010L
///
/// Indicates that the hInstance and lpTemplateName members specify a dialog box template to use in place of the default template.
///
///
/// -
/// CF_ENABLETEMPLATEHANDLE 0x00000020L
///
/// Indicates that the hInstance member identifies a data block that contains a preloaded dialog box template. The system
/// ignores the lpTemplateName member if this flag is specified.
///
///
/// -
/// CF_FIXEDPITCHONLY 0x00004000L
/// ChooseFont should enumerate and allow selection of only fixed-pitch fonts.
///
/// -
/// CF_FORCEFONTEXIST 0x00010000L
///
/// ChooseFont should indicate an error condition if the user attempts to select a font or style that is not listed in the
/// dialog box.
///
///
/// -
/// CF_INACTIVEFONTS 0x02000000L
///
/// ChooseFont should additionally display fonts that are set to Hide in Fonts Control Panel. Windows Vista and Windows XP/2000:
/// This flag is not supported until Windows 7.
///
///
/// -
/// CF_INITTOLOGFONTSTRUCT 0x00000040L
/// ChooseFont should use the structure pointed to by the lpLogFont member to initialize the dialog box controls.
///
/// -
/// CF_LIMITSIZE 0x00002000L
/// ChooseFont should select only font sizes within the range specified by the nSizeMin and nSizeMax members.
///
/// -
/// CF_NOOEMFONTS 0x00000800L
/// Same as the CF_NOVECTORFONTS flag.
///
/// -
/// CF_NOFACESEL 0x00080000L
///
/// When using a LOGFONT structure to initialize the dialog box controls, use this flag to prevent the dialog box from
/// displaying an initial selection for the font name combo box. This is useful when there is no single font name that applies
/// to the text selection.
///
///
/// -
/// CF_NOSCRIPTSEL 0x00800000L
///
/// Disables the Script combo box. When this flag is set, the lfCharSet member of the LOGFONT structure is set to
/// DEFAULT_CHARSET when ChooseFont returns. This flag is used only to initialize the dialog box.
///
///
/// -
/// CF_NOSIMULATIONS 0x00001000L
/// ChooseFont should not display or allow selection of font simulations.
///
/// -
/// CF_NOSIZESEL 0x00200000L
///
/// When using a structure to initialize the dialog box controls, use this flag to prevent the dialog box from displaying an
/// initial selection for the Font Size combo box. This is useful when there is no single font size that applies to the text selection.
///
///
/// -
/// CF_NOSTYLESEL 0x00100000L
///
/// When using a LOGFONT structure to initialize the dialog box controls, use this flag to prevent the dialog box from
/// displaying an initial selection for the Font Style combo box. This is useful when there is no single font style that applies
/// to the text selection.
///
///
/// -
/// CF_NOVECTORFONTS 0x00000800L
/// ChooseFont should not allow vector font selections.
///
/// -
/// CF_NOVERTFONTS 0x01000000L
/// Causes the Font dialog box to list only horizontally oriented fonts.
///
/// -
/// CF_PRINTERFONTS 0x00000002
///
/// This flag is ignored for font enumeration. Windows Vista and Windows XP/2000: Causes the dialog box to list only the fonts
/// supported by the printer associated with the device context or information context identified by the hDC member. It also
/// causes the font type description label to appear at the bottom of the Font dialog box.
///
///
/// -
/// CF_SCALABLEONLY 0x00020000L
///
/// Specifies that ChooseFont should allow only the selection of scalable fonts. Scalable fonts include vector fonts, scalable
/// printer fonts, TrueType fonts, and fonts scaled by other technologies.
///
///
/// -
/// CF_SCREENFONTS 0x00000001
///
/// This flag is ignored for font enumeration. Windows Vista and Windows XP/2000: Causes the dialog box to list only the screen
/// fonts supported by the system.
///
///
/// -
/// CF_SCRIPTSONLY 0x00000400L
///
/// ChooseFont should allow selection of fonts for all non-OEM and Symbol character sets, as well as the ANSI character set.
/// This supersedes the CF_ANSIONLY value.
///
///
/// -
/// CF_SELECTSCRIPT 0x00400000L
///
/// When specified on input, only fonts with the character set identified in the lfCharSet member of the LOGFONT structure are
/// displayed. The user will not be allowed to change the character set specified in the Scripts combo box.
///
///
/// -
/// CF_SHOWHELP 0x00000004L
///
/// Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING
/// registered messages that the dialog box sends when the user clicks the Help button.
///
///
/// -
/// CF_TTONLY 0x00040000L
/// ChooseFont should only enumerate and allow the selection of TrueType fonts.
///
/// -
/// CF_USESTYLE 0x00000080L
///
/// The lpszStyle member is a pointer to a buffer that contains style data that ChooseFont should use to initialize the Font
/// Style combo box. When the user closes the dialog box, ChooseFont copies style data for the user's selection to this buffer.
///
///
/// -
/// CF_WYSIWYG 0x00008000L
///
/// Obsolete. ChooseFont ignores this flag. Windows Vista and Windows XP/2000: ChooseFont should allow only the selection of
/// fonts available on both the printer and the display. If this flag is specified, the CF_SCREENSHOTS and CF_PRINTERFONTS, or
/// CF_BOTH flags should also be specified.
///
///
///
///
public CF Flags;
///
/// Type: COLORREF
///
/// If the CF_EFFECTS flag is set, rgbColors specifies the initial text color. When ChooseFont returns
/// successfully, this member contains the RGB value of the text color that the user selected. To create a COLORREF color value,
/// use the RGB macro.
///
///
public COLORREF rgbColors;
///
/// Type: LPARAM
///
/// Application-defined data that the system passes to the hook procedure identified by the lpfnHook member. When the
/// system sends the WM_INITDIALOG message to the hook procedure, the message's lParam parameter is a pointer to the CHOOSEFONT
/// structure specified when the dialog was created. The hook procedure can use this pointer to get the lCustData value.
///
///
public IntPtr lCustData;
///
/// Type: LPCFHOOKPROC
///
/// A pointer to a CFHookProc hook procedure that can process messages intended for the dialog box. This member is ignored
/// unless the CF_ENABLEHOOK flag is set in the Flags member.
///
///
[MarshalAs(UnmanagedType.FunctionPtr)]
public LPCFHOOKPROC lpfnHook;
///
/// Type: LPCTSTR
///
/// The name of the dialog box template resource in the module identified by the hInstance member. This template is
/// substituted for the standard dialog box template. For numbered dialog box resources, lpTemplateName can be a value
/// returned by the MAKEINTRESOURCE macro. This member is ignored unless the CF_ENABLETEMPLATE flag is set in the
/// Flags member.
///
///
[MarshalAs(UnmanagedType.LPTStr)]
public string lpTemplateName;
///
/// Type: HINSTANCE
///
/// If the CF_ENABLETEMPLATEHANDLE flag is set in the Flags member, hInstance is a handle to a memory
/// object containing a dialog box template. If the CF_ENABLETEMPLATE flag is set, hInstance is a handle to a
/// module that contains a dialog box template named by the lpTemplateName member. If neither
/// CF_ENABLETEMPLATEHANDLE nor CF_ENABLETEMPLATE is set, this member is ignored.
///
///
public HINSTANCE hInstance;
///
/// Type: LPTSTR
///
/// The style data. If the CF_USESTYLE flag is specified, ChooseFont uses the data in this buffer to initialize the
/// Font Style combo box. When the user closes the dialog box, ChooseFont copies the string in the Font
/// Style combo box into this buffer.
///
///
public StrPtrAuto lpszStyle;
///
/// Type: WORD
/// The type of the selected font when ChooseFont returns. This member can be one or more of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// BOLD_FONTTYPE 0x0100
///
/// The font weight is bold. This information is duplicated in the lfWeight member of the LOGFONT structure and is equivalent to FW_BOLD.
///
///
/// -
/// ITALIC_FONTTYPE 0x0200
/// The italic font attribute is set. This information is duplicated in the lfItalic member of the LOGFONT structure.
///
/// -
/// PRINTER_FONTTYPE 0x4000
/// The font is a printer font.
///
/// -
/// REGULAR_FONTTYPE 0x0400
///
/// The font weight is normal. This information is duplicated in the lfWeight member of the LOGFONT structure and is equivalent
/// to FW_REGULAR.
///
///
/// -
/// SCREEN_FONTTYPE 0x2000
/// The font is a screen font.
///
/// -
/// SIMULATED_FONTTYPE 0x8000
/// The font is simulated by the graphics device interface (GDI).
///
///
///
public ushort nFontType;
///
private ushort ___MISSING_ALIGNMENT__;
///
/// Type: INT
///
/// The minimum point size a user can select. ChooseFont recognizes this member only if the CF_LIMITSIZE flag is specified.
///
///
public int nSizeMin;
///
/// Type: INT
///
/// The maximum point size a user can select. ChooseFont recognizes this member only if the CF_LIMITSIZE flag is specified.
///
///
public int nSizeMax;
}
///
/// Contains strings that identify the driver, device, and output port names for a printer. These strings must be ANSI strings when
/// the ANSI version of PrintDlg or PrintDlgEx is used, and must be Unicode strings when the Unicode version of PrintDlg or
/// PrintDlgEx is used. The PrintDlgEx and PrintDlg functions use these strings to initialize the
/// system-defined Print Property Sheet or Print Dialog Box. When the user closes the property sheet or dialog box, information
/// about the selected printer is returned in this structure.
///
// https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-devnames typedef struct tagDEVNAMES { WORD wDriverOffset;
// WORD wDeviceOffset; WORD wOutputOffset; WORD wDefault; } DEVNAMES;
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagDEVNAMES")]
[StructLayout(LayoutKind.Sequential)]
public struct DEVNAMES
{
///
/// Type: WORD
///
/// The offset, in characters, from the beginning of this structure to a null-terminated string that contains the file name
/// (without the extension) of the device driver. On input, this string is used to determine the printer to display initially in
/// the dialog box.
///
///
public ushort wDriverOffset;
///
/// Type: WORD
///
/// The offset, in characters, from the beginning of this structure to the null-terminated string that contains the name of the device.
///
///
public ushort wDeviceOffset;
///
/// Type: WORD
///
/// The offset, in characters, from the beginning of this structure to the null-terminated string that contains the device name
/// for the physical output medium (output port).
///
///
public ushort wOutputOffset;
///
/// Type: WORD
///
/// Indicates whether the strings contained in the DEVNAMES structure identify the default printer. This string is used
/// to verify that the default printer has not changed since the last print operation. If any of the strings do not match, a
/// warning message is displayed informing the user that the document may need to be reformatted. On output, the wDefault
/// member is changed only if the Print Setup dialog box was displayed and the user chose the OK button. The
/// DN_DEFAULTPRN flag is used if the default printer was selected. If a specific printer is selected, the flag is not
/// used. All other flags in this member are reserved for internal use by the dialog box procedure for the Print property
/// sheet or Print dialog box.
///
///
public DN wDefault;
}
///
/// Contains information that the FindText and ReplaceText functions use to initialize the Find and Replace dialog
/// boxes. The FINDMSGSTRING registered message uses this structure to pass the user's search or replacement input to the owner
/// window of a Find or Replace dialog box.
///
// https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-findreplacea typedef struct tagFINDREPLACEA { DWORD
// lStructSize; HWND hwndOwner; HINSTANCE hInstance; DWORD Flags; LPSTR lpstrFindWhat; LPSTR lpstrReplaceWith; WORD wFindWhatLen;
// WORD wReplaceWithLen; LPARAM lCustData; LPFRHOOKPROC lpfnHook; LPCSTR lpTemplateName; } FINDREPLACEA, *LPFINDREPLACEA;
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagFINDREPLACEA")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct FINDREPLACE
{
///
/// Type: DWORD
/// The length, in bytes, of the structure.
///
public uint lStructSize;
///
/// Type: HWND
///
/// A handle to the window that owns the dialog box. The window procedure of the specified window receives FINDMSGSTRING
/// messages from the dialog box. This member can be any valid window handle, but it must not be NULL.
///
///
public HWND hwndOwner;
///
/// Type: HINSTANCE
///
/// If the FR_ENABLETEMPLATEHANDLE flag is set in the Flags, hInstance is a handle to a memory object
/// containing a dialog box template. If the FR_ENABLETEMPLATE flag is set, hInstance is a handle to a module that
/// contains a dialog box template named by the lpTemplateName member. If neither flag is set, this member is ignored.
///
///
public HINSTANCE hInstance;
///
/// Type: DWORD
///
/// A set of bit flags that you can use to initialize the dialog box. The dialog box sets these flags when it sends the
/// FINDMSGSTRING registered message to indicate the user's input. This member can be one or more of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// FR_DIALOGTERM 0x00000040
///
/// If set in a FINDMSGSTRING message, indicates that the dialog box is closing. When you receive a message with this flag set,
/// the dialog box handle returned by the FindText or ReplaceText function is no longer valid.
///
///
/// -
/// FR_DOWN 0x00000001
///
/// If set, the Down button of the direction radio buttons in a Find dialog box is selected indicating that you should search
/// from the current location to the end of the document. If not set, the Up button is selected so you should search to the
/// beginning of the document. You can set this flag to initialize the dialog box. If set in a FINDMSGSTRING message, indicates
/// the user's selection.
///
///
/// -
/// FR_ENABLEHOOK 0x00000100
/// Enables the hook function specified in the lpfnHook member. This flag is used only to initialize the dialog box.
///
/// -
/// FR_ENABLETEMPLATE 0x00000200
///
/// Indicates that the hInstance and lpTemplateName members specify a dialog box template to use in place of the default
/// template. This flag is used only to initialize the dialog box.
///
///
/// -
/// FR_ENABLETEMPLATEHANDLE 0x00002000
///
/// Indicates that the hInstance member identifies a data block that contains a preloaded dialog box template. The system
/// ignores the lpTemplateName member if this flag is specified.
///
///
/// -
/// FR_FINDNEXT 0x00000008
///
/// If set in a FINDMSGSTRING message, indicates that the user clicked the Find Next button in a Find or Replace dialog box. The
/// lpstrFindWhat member specifies the string to search for.
///
///
/// -
/// FR_HIDEUPDOWN 0x00004000
/// If set when initializing a Find dialog box, hides the search direction radio buttons.
///
/// -
/// FR_HIDEMATCHCASE 0x00008000
/// If set when initializing a Find or Replace dialog box, hides the Match Case check box.
///
/// -
/// FR_HIDEWHOLEWORD 0x00010000
/// If set when initializing a Find or Replace dialog box, hides the Match Whole Word Only check box.
///
/// -
/// FR_MATCHCASE 0x00000004
///
/// If set, the Match Case check box is selected indicating that the search should be case-sensitive. If not set, the check box
/// is unselected so the search should be case-insensitive. You can set this flag to initialize the dialog box. If set in a
/// FINDMSGSTRING message, indicates the user's selection.
///
///
/// -
/// FR_NOMATCHCASE 0x00000800
/// If set when initializing a Find or Replace dialog box, disables the Match Case check box.
///
/// -
/// FR_NOUPDOWN 0x00000400
/// If set when initializing a Find dialog box, disables the search direction radio buttons.
///
/// -
/// FR_NOWHOLEWORD 0x00001000
/// If set when initializing a Find or Replace dialog box, disables the Whole Word check box.
///
/// -
/// FR_REPLACE 0x00000010
///
/// If set in a FINDMSGSTRING message, indicates that the user clicked the Replace button in a Replace dialog box. The
/// lpstrFindWhat member specifies the string to be replaced and the lpstrReplaceWith member specifies the replacement string.
///
///
/// -
/// FR_REPLACEALL 0x00000020
///
/// If set in a FINDMSGSTRING message, indicates that the user clicked the Replace All button in a Replace dialog box. The
/// lpstrFindWhat member specifies the string to be replaced and the lpstrReplaceWith member specifies the replacement string.
///
///
/// -
/// FR_SHOWHELP 0x00000080
///
/// Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING
/// registered messages that the dialog box sends when the user clicks the Help button.
///
///
/// -
/// FR_WHOLEWORD 0x00000002
///
/// If set, the Match Whole Word Only check box is selected indicating that you should search only for whole words that match
/// the search string. If not set, the check box is unselected so you should also search for word fragments that match the
/// search string. You can set this flag to initialize the dialog box. If set in a FINDMSGSTRING message, indicates the user's selection.
///
///
///
///
public FR Flags;
///
/// Type: LPTSTR
///
/// The search string that the user typed in the Find What edit control. You must dynamically allocate the buffer or use
/// a global or static array so it does not go out of scope before the dialog box closes. The buffer should be at least 80
/// characters long. If the buffer contains a string when you initialize the dialog box, the string is displayed in the Find
/// What edit control. If a FINDMSGSTRING message specifies the FR_FINDNEXT flag, lpstrFindWhat contains the
/// string to search for. The FR_DOWN, FR_WHOLEWORD, and FR_MATCHCASE flags indicate the direction and type
/// of search. If a FINDMSGSTRING message specifies the FR_REPLACE or FR_REPLACE flags,
/// lpstrFindWhat contains the string to be replaced.
///
///
public StrPtrAuto lpstrFindWhat;
///
/// Type: LPTSTR
///
/// The replacement string that the user typed in the Replace With edit control. You must dynamically allocate the buffer
/// or use a global or static array so it does not go out of scope before the dialog box closes. If the buffer contains a string
/// when you initialize the dialog box, the string is displayed in the Replace With edit control.
///
///
/// If a FINDMSGSTRING message specifies the FR_REPLACE or FR_REPLACEALL flags, lpstrReplaceWith contains
/// the replacement string .
///
/// The FindText function ignores this member.
///
public StrPtrAuto lpstrReplaceWith;
///
/// Type: WORD
/// The length, in bytes, of the buffer pointed to by the lpstrFindWhat member.
///
public ushort wFindWhatLen;
///
/// Type: WORD
/// The length, in bytes, of the buffer pointed to by the lpstrReplaceWith member.
///
public ushort wReplaceWithLen;
///
/// Type: LPARAM
///
/// Application-defined data that the system passes to the hook procedure identified by the lpfnHook member. When the
/// system sends the WM_INITDIALOG message to the hook procedure, the message's lParam parameter is a pointer to the
/// FINDREPLACE structure specified when the dialog was created. The hook procedure can use this pointer to get the
/// lCustData value.
///
///
public IntPtr lCustData;
///
/// Type: LPFRHOOKPROC
///
/// A pointer to an FRHookProc hook procedure that can process messages intended for the dialog box. This member is ignored
/// unless the FR_ENABLEHOOK flag is set in the Flags member. If the hook procedure returns FALSE in
/// response to the WM_INITDIALOG message, the hook procedure must display the dialog box or else the dialog box will not be
/// shown. To do this, first perform any other paint operations, and then call the ShowWindow and UpdateWindow functions.
///
///
[MarshalAs(UnmanagedType.FunctionPtr)]
public LPFRHOOKPROC lpfnHook;
///
/// Type: LPCTSTR
///
/// The name of the dialog box template resource in the module identified by the hInstance member. This template is
/// substituted for the standard dialog box template. For numbered dialog box resources, this can be a value returned by the
/// MAKEINTRESOURCE macro. This member is ignored unless the FR_ENABLETEMPLATE flag is set in the Flags member.
///
///
[MarshalAs(UnmanagedType.LPTStr)]
public string lpTemplateName;
}
///
/// Contains information about a WM_NOTIFY message sent to an OFNHookProc hook procedure for an Open or Save As dialog
/// box. The lParam parameter of the WM_NOTIFY message is a pointer to an OFNOTIFY structure.
///
///
/// Not all of the Open and Save As notification messages use the OFNOTIFY structure. The CDN_INCLUDEITEM
/// notification message uses the OFNOTIFYEX structure.
///
// https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-ofnotifya typedef struct _OFNOTIFYA { NMHDR hdr;
// LPOPENFILENAMEA lpOFN; LPSTR pszFile; } OFNOTIFYA, *LPOFNOTIFYA;
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg._OFNOTIFYA")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct OFNOTIFY
{
///
/// Type: NMHDR
///
/// The code member of this structure can be one of the following notification messages that identify the message being
/// sent: CDN_FILEOK, CDN_FOLDERCHANGE, CDN_HELP, CDN_INITDONE, CDN_SELCHANGE, CDN_SHAREVIOLATION, CDN_TYPECHANGE.
///
///
public NMHDR hdr;
///
/// Type: LPOPENFILENAME
///
/// A pointer to the OPENFILENAME structure that was specified when the Open or Save As dialog box was created.
/// For some of the notification messages, this structure contains additional information about the event that caused the notification.
///
///
public IntPtr lpOFN;
///
/// Type: LPTSTR
///
/// The file name for which a network sharing violation has occurred. This member is valid only with the CDN_SHAREVIOLATION
/// notification message.
///
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pszFile;
}
/// Contains information about a CDN_INCLUDEITEM notification message.
// https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-ofnotifyexa typedef struct _OFNOTIFYEXA { NMHDR hdr;
// LPOPENFILENAMEA lpOFN; LPVOID psf; LPVOID pidl; } OFNOTIFYEXA, *LPOFNOTIFYEXA;
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg._OFNOTIFYEXA")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct OFNOTIFYEX
{
///
/// Type: NMHDR
/// The code member of this structure identifies the notification message being sent.
///
public NMHDR hdr;
///
/// Type: LPOPENFILENAME
///
/// A pointer to an OPENFILENAME structure containing the values specified when the Open or Save As dialog box was created.
///
///
public IntPtr lpOFN;
///
/// Type: LPVOID
/// A pointer to the interface for the folder or shell name-space extension whose items are being enumerated.
///
[MarshalAs(UnmanagedType.Interface)]
public object psf;
///
/// Type: LPVOID
///
/// A pointer to an item identifier list that identifies an item in the container identified by the psf member. The item
/// identifier is relative to the psf container.
///
///
public IntPtr pidl;
}
///
///
/// [Starting with Windows Vista, the Open and Save As common dialog boxes have been superseded by the Common Item
/// Dialog. We recommended that you use the Common Item Dialog API instead of these dialog boxes from the Common Dialog Box Library.]
///
///
/// Contains information that the GetOpenFileName and GetSaveFileName functions use to initialize an Open or Save As
/// dialog box. After the user closes the dialog box, the system returns information about the user's selection in this structure.
///
///
///
/// For compatibility reasons, the Places Bar is hidden if Flags is set to OFN_ENABLEHOOK and lStructSize is OPENFILENAME_SIZE_VERSION_400.
///
// https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-openfilenamea typedef struct tagOFNA { DWORD lStructSize;
// HWND hwndOwner; HINSTANCE hInstance; LPCSTR lpstrFilter; LPSTR lpstrCustomFilter; DWORD nMaxCustFilter; DWORD nFilterIndex; LPSTR
// lpstrFile; DWORD nMaxFile; LPSTR lpstrFileTitle; DWORD nMaxFileTitle; LPCSTR lpstrInitialDir; LPCSTR lpstrTitle; DWORD Flags;
// WORD nFileOffset; WORD nFileExtension; LPCSTR lpstrDefExt; LPARAM lCustData; LPOFNHOOKPROC lpfnHook; LPCSTR lpTemplateName;
// LPEDITMENU lpEditInfo; LPCSTR lpstrPrompt; void *pvReserved; DWORD dwReserved; DWORD FlagsEx; } OPENFILENAMEA, *LPOPENFILENAMEA;
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagOFNA")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct OPENFILENAME
{
///
/// Type: DWORD
/// The length, in bytes, of the structure. Use
/// sizeof (OPENFILENAME)
/// for this parameter.
///
///
public uint lStructSize;
///
/// Type: HWND
///
/// A handle to the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the
/// dialog box has no owner.
///
///
public HWND hwndOwner;
///
/// Type: HINSTANCE
///
/// If the OFN_ENABLETEMPLATEHANDLE flag is set in the Flags member, hInstance is a handle to a memory
/// object containing a dialog box template. If the OFN_ENABLETEMPLATE flag is set, hInstance is a handle to a
/// module that contains a dialog box template named by the lpTemplateName member. If neither flag is set, this member is
/// ignored. If the OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a
/// child of the default Explorer-style dialog box. If the OFN_EXPLORER flag is not set, the system uses the template to
/// create an old-style dialog box that replaces the default dialog box.
///
///
public HINSTANCE hInstance;
///
/// Type: LPCTSTR
///
/// A buffer containing pairs of null-terminated filter strings. The last string in the buffer must be terminated by two
/// NULL characters.
///
///
/// The first string in each pair is a display string that describes the filter (for example, "Text Files"), and the second
/// string specifies the filter pattern (for example, ".TXT"). To specify multiple filter patterns for a single display string,
/// use a semicolon to separate the patterns (for example, ".TXT;.DOC;.BAK"). A pattern string can be a combination of valid
/// file name characters and the asterisk (*) wildcard character. Do not include spaces in the pattern string.
///
///
/// The system does not change the order of the filters. It displays them in the File Types combo box in the order
/// specified in lpstrFilter.
///
/// If lpstrFilter is NULL, the dialog box does not display any filters.
///
/// In the case of a shortcut, if no filter is set, GetOpenFileName and GetSaveFileName retrieve the name of the .lnk file, not
/// its target. This behavior is the same as setting the OFN_NODEREFERENCELINKS flag in the Flags member. To
/// retrieve a shortcut's target without filtering, use the string
/// "All Files\0*.*\0\0"
/// .
///
///
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrFilter;
///
/// Type: LPTSTR
///
/// A static buffer that contains a pair of null-terminated filter strings for preserving the filter pattern chosen by the user.
/// The first string is your display string that describes the custom filter, and the second string is the filter pattern
/// selected by the user. The first time your application creates the dialog box, you specify the first string, which can be any
/// nonempty string. When the user selects a file, the dialog box copies the current filter pattern to the second string. The
/// preserved filter pattern can be one of the patterns specified in the lpstrFilter buffer, or it can be a filter
/// pattern typed by the user. The system uses the strings to initialize the user-defined file filter the next time the dialog
/// box is created. If the nFilterIndex member is zero, the dialog box uses the custom filter.
///
/// If this member is NULL, the dialog box does not preserve user-defined filter patterns.
///
/// If this member is not NULL, the value of the nMaxCustFilter member must specify the size, in characters, of
/// the lpstrCustomFilter buffer.
///
///
public StrPtrAuto lpstrCustomFilter;
///
/// Type: DWORD
///
/// The size, in characters, of the buffer identified by lpstrCustomFilter. This buffer should be at least 40 characters
/// long. This member is ignored if lpstrCustomFilter is NULL or points to a NULL string.
///
///
public uint nMaxCustFilter;
///
/// Type: DWORD
///
/// The index of the currently selected filter in the File Types control. The buffer pointed to by lpstrFilter
/// contains pairs of strings that define the filters. The first pair of strings has an index value of 1, the second pair 2, and
/// so on. An index of zero indicates the custom filter specified by lpstrCustomFilter. You can specify an index on input
/// to indicate the initial filter description and filter pattern for the dialog box. When the user selects a file,
/// nFilterIndex returns the index of the currently displayed filter. If nFilterIndex is zero and
/// lpstrCustomFilter is NULL, the system uses the first filter in the lpstrFilter buffer. If all three
/// members are zero or NULL, the system does not use any filters and does not show any files in the file list control of
/// the dialog box.
///
///
public uint nFilterIndex;
///
/// Type: LPTSTR
///
/// The file name used to initialize the File Name edit control. The first character of this buffer must be NULL
/// if initialization is not necessary. When the GetOpenFileName or GetSaveFileName function returns successfully, this buffer
/// contains the drive designator, path, file name, and extension of the selected file.
///
///
/// If the OFN_ALLOWMULTISELECT flag is set and the user selects multiple files, the buffer contains the current
/// directory followed by the file names of the selected files. For Explorer-style dialog boxes, the directory and file name
/// strings are NULL separated, with an extra NULL character after the last file name. For old-style dialog boxes,
/// the strings are space separated and the function uses short file names for file names with spaces. You can use the
/// FindFirstFile function to convert between long and short file names. If the user selects only one file, the lpstrFile
/// string does not have a separator between the path and file name.
///
///
/// If the buffer is too small, the function returns FALSE and the CommDlgExtendedError function returns
/// FNERR_BUFFERTOOSMALL. In this case, the first two bytes of the lpstrFile buffer contain the required size, in
/// bytes or characters.
///
///
public StrPtrAuto lpstrFile;
///
/// Type: DWORD
///
/// The size, in characters, of the buffer pointed to by lpstrFile. The buffer must be large enough to store the path and
/// file name string or strings, including the terminating NULL character. The GetOpenFileName and GetSaveFileName
/// functions return FALSE if the buffer is too small to contain the file information. The buffer should be at least 256
/// characters long.
///
///
public uint nMaxFile;
///
/// Type: LPTSTR
/// The file name and extension (without path information) of the selected file. This member can be NULL.
///
public StrPtrAuto lpstrFileTitle;
///
/// Type: DWORD
///
/// The size, in characters, of the buffer pointed to by lpstrFileTitle. This member is ignored if lpstrFileTitle
/// is NULL.
///
///
public uint nMaxFileTitle;
///
/// Type: LPCTSTR
/// The initial directory. The algorithm for selecting the initial directory varies on different platforms.
/// Windows 7:
///
/// -
///
/// If lpstrInitialDir has the same value as was passed the first time the application used an Open or Save
/// As dialog box, the path most recently selected by the user is used as the initial directory.
///
///
/// -
/// Otherwise, if lpstrFile contains a path, that path is the initial directory.
///
/// -
/// Otherwise, if lpstrInitialDir is not NULL, it specifies the initial directory.
///
/// -
///
/// If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the
/// initial directory is the current directory.
///
///
/// -
/// Otherwise, the initial directory is the personal files directory of the current user.
///
/// -
/// Otherwise, the initial directory is the Desktop folder.
///
///
/// Windows 2000/XP/Vista:
///
/// -
/// If lpstrFile contains a path, that path is the initial directory.
///
/// -
/// Otherwise, lpstrInitialDir specifies the initial directory.
///
/// -
///
/// Otherwise, if the application has used an Open or Save As dialog box in the past, the path most recently used
/// is selected as the initial directory. However, if an application is not run for a long time, its saved selected path is discarded.
///
///
/// -
///
/// If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the
/// initial directory is the current directory.
///
///
/// -
/// Otherwise, the initial directory is the personal files directory of the current user.
///
/// -
/// Otherwise, the initial directory is the Desktop folder.
///
///
///
public StrPtrAuto lpstrInitialDir;
///
/// Type: LPCTSTR
///
/// A string to be placed in the title bar of the dialog box. If this member is NULL, the system uses the default title
/// (that is, Save As or Open).
///
///
public StrPtrAuto lpstrTitle;
///
/// Type: DWORD
///
/// A set of bit flags you can use to initialize the dialog box. When the dialog box returns, it sets these flags to indicate
/// the user's input. This member can be a combination of the following flags.
///
///
///
/// Value
/// Meaning
///
/// -
/// OFN_ALLOWMULTISELECT 0x00000200
///
/// The File Name list box allows multiple selections. If you also set the OFN_EXPLORER flag, the dialog box uses the
/// Explorer-style user interface; otherwise, it uses the old-style user interface. If the user selects more than one file, the
/// lpstrFile buffer returns the path to the current directory followed by the file names of the selected files. The nFileOffset
/// member is the offset, in bytes or characters, to the first file name, and the nFileExtension member is not used. For
/// Explorer-style dialog boxes, the directory and file name strings are NULL separated, with an extra NULL character after the
/// last file name. This format enables the Explorer-style dialog boxes to return long file names that include spaces. For
/// old-style dialog boxes, the directory and file name strings are separated by spaces and the function uses short file names
/// for file names with spaces. You can use the FindFirstFile function to convert between long and short file names. If you
/// specify a custom template for an old-style dialog box, the definition of the File Name list box must contain the
/// LBS_EXTENDEDSEL value.
///
///
/// -
/// OFN_CREATEPROMPT 0x00002000
///
/// If the user specifies a file that does not exist, this flag causes the dialog box to prompt the user for permission to
/// create the file. If the user chooses to create the file, the dialog box closes and the function returns the specified name;
/// otherwise, the dialog box remains open. If you use this flag with the OFN_ALLOWMULTISELECT flag, the dialog box allows the
/// user to specify only one nonexistent file.
///
///
/// -
/// OFN_DONTADDTORECENT 0x02000000
///
/// Prevents the system from adding a link to the selected file in the file system directory that contains the user's most
/// recently used documents. To retrieve the location of this directory, call the SHGetSpecialFolderLocation function with the
/// CSIDL_RECENT flag.
///
///
/// -
/// OFN_ENABLEHOOK 0x00000020
/// Enables the hook function specified in the lpfnHook member.
///
/// -
/// OFN_ENABLEINCLUDENOTIFY 0x00400000
///
/// Causes the dialog box to send CDN_INCLUDEITEM notification messages to your OFNHookProc hook procedure when the user opens a
/// folder. The dialog box sends a notification for each item in the newly opened folder. These messages enable you to control
/// which items the dialog box displays in the folder's item list.
///
///
/// -
/// OFN_ENABLESIZING 0x00800000
///
/// Enables the Explorer-style dialog box to be resized using either the mouse or the keyboard. By default, the Explorer-style
/// Open and Save As dialog boxes allow the dialog box to be resized regardless of whether this flag is set. This flag is
/// necessary only if you provide a hook procedure or custom template. The old-style dialog box does not permit resizing.
///
///
/// -
/// OFN_ENABLETEMPLATE 0x00000040
///
/// The lpTemplateName member is a pointer to the name of a dialog template resource in the module identified by the hInstance
/// member. If the OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of
/// the default Explorer-style dialog box. If the OFN_EXPLORER flag is not set, the system uses the template to create an
/// old-style dialog box that replaces the default dialog box.
///
///
/// -
/// OFN_ENABLETEMPLATEHANDLE 0x00000080
///
/// The hInstance member identifies a data block that contains a preloaded dialog box template. The system ignores
/// lpTemplateName if this flag is specified. If the OFN_EXPLORER flag is set, the system uses the specified template to create
/// a dialog box that is a child of the default Explorer-style dialog box. If the OFN_EXPLORER flag is not set, the system uses
/// the template to create an old-style dialog box that replaces the default dialog box.
///
///
/// -
/// OFN_EXPLORER 0x00080000
///
/// Indicates that any customizations made to the Open or Save As dialog box use the Explorer-style customization methods. For
/// more information, see Explorer-Style Hook Procedures and Explorer-Style Custom Templates. By default, the Open and Save As
/// dialog boxes use the Explorer-style user interface regardless of whether this flag is set. This flag is necessary only if
/// you provide a hook procedure or custom template, or set the OFN_ALLOWMULTISELECT flag. If you want the old-style user
/// interface, omit the OFN_EXPLORER flag and provide a replacement old-style template or hook procedure. If you want the old
/// style but do not need a custom template or hook procedure, simply provide a hook procedure that always returns FALSE.
///
///
/// -
/// OFN_EXTENSIONDIFFERENT 0x00000400
///
/// The user typed a file name extension that differs from the extension specified by lpstrDefExt. The function does not use
/// this flag if lpstrDefExt is NULL.
///
///
/// -
/// OFN_FILEMUSTEXIST 0x00001000
///
/// The user can type only names of existing files in the File Name entry field. If this flag is specified and the user enters
/// an invalid name, the dialog box procedure displays a warning in a message box. If this flag is specified, the
/// OFN_PATHMUSTEXIST flag is also used. This flag can be used in an Open dialog box. It cannot be used with a Save As dialog box.
///
///
/// -
/// OFN_FORCESHOWHIDDEN 0x10000000
///
/// Forces the showing of system and hidden files, thus overriding the user setting to show or not show hidden files. However, a
/// file that is marked both system and hidden is not shown.
///
///
/// -
/// OFN_HIDEREADONLY 0x00000004
/// Hides the Read Only check box.
///
/// -
/// OFN_LONGNAMES 0x00200000
///
/// For old-style dialog boxes, this flag causes the dialog box to use long file names. If this flag is not specified, or if the
/// OFN_ALLOWMULTISELECT flag is also set, old-style dialog boxes use short file names (8.3 format) for file names with spaces.
/// Explorer-style dialog boxes ignore this flag and always display long file names.
///
///
/// -
/// OFN_NOCHANGEDIR 0x00000008
///
/// Restores the current directory to its original value if the user changed the directory while searching for files. This flag
/// is ineffective for GetOpenFileName.
///
///
/// -
/// OFN_NODEREFERENCELINKS 0x00100000
///
/// Directs the dialog box to return the path and file name of the selected shortcut (.LNK) file. If this value is not
/// specified, the dialog box returns the path and file name of the file referenced by the shortcut.
///
///
/// -
/// OFN_NOLONGNAMES 0x00040000
///
/// For old-style dialog boxes, this flag causes the dialog box to use short file names (8.3 format). Explorer-style dialog
/// boxes ignore this flag and always display long file names.
///
///
/// -
/// OFN_NONETWORKBUTTON 0x00020000
/// Hides and disables the Network button.
///
/// -
/// OFN_NOREADONLYRETURN 0x00008000
/// The returned file does not have the Read Only check box selected and is not in a write-protected directory.
///
/// -
/// OFN_NOTESTFILECREATE 0x00010000
///
/// The file is not created before the dialog box is closed. This flag should be specified if the application saves the file on
/// a create-nonmodify network share. When an application specifies this flag, the library does not check for write protection,
/// a full disk, an open drive door, or network protection. Applications using this flag must perform file operations carefully,
/// because a file cannot be reopened once it is closed.
///
///
/// -
/// OFN_NOVALIDATE 0x00000100
///
/// The common dialog boxes allow invalid characters in the returned file name. Typically, the calling application uses a hook
/// procedure that checks the file name by using the FILEOKSTRING message. If the text box in the edit control is empty or
/// contains nothing but spaces, the lists of files and directories are updated. If the text box in the edit control contains
/// anything else, nFileOffset and nFileExtension are set to values generated by parsing the text. No default extension is added
/// to the text, nor is text copied to the buffer specified by lpstrFileTitle. If the value specified by nFileOffset is less
/// than zero, the file name is invalid. Otherwise, the file name is valid, and nFileExtension and nFileOffset can be used as if
/// the OFN_NOVALIDATE flag had not been specified.
///
///
/// -
/// OFN_OVERWRITEPROMPT 0x00000002
///
/// Causes the Save As dialog box to generate a message box if the selected file already exists. The user must confirm whether
/// to overwrite the file.
///
///
/// -
/// OFN_PATHMUSTEXIST 0x00000800
///
/// The user can type only valid paths and file names. If this flag is used and the user types an invalid path and file name in
/// the File Name entry field, the dialog box function displays a warning in a message box.
///
///
/// -
/// OFN_READONLY 0x00000001
///
/// Causes the Read Only check box to be selected initially when the dialog box is created. This flag indicates the state of the
/// Read Only check box when the dialog box is closed.
///
///
/// -
/// OFN_SHAREAWARE 0x00004000
///
/// Specifies that if a call to the OpenFile function fails because of a network sharing violation, the error is ignored and the
/// dialog box returns the selected file name. If this flag is not set, the dialog box notifies your hook procedure when a
/// network sharing violation occurs for the file name specified by the user. If you set the OFN_EXPLORER flag, the dialog box
/// sends the CDN_SHAREVIOLATION message to the hook procedure. If you do not set OFN_EXPLORER, the dialog box sends the
/// SHAREVISTRING registered message to the hook procedure.
///
///
/// -
/// OFN_SHOWHELP 0x00000010
///
/// Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING
/// registered messages that the dialog box sends when the user clicks the Help button. An Explorer-style dialog box sends a
/// CDN_HELP notification message to your hook procedure when the user clicks the Help button.
///
///
///
///
public OFN Flags;
///
/// Type: WORD
///
/// The zero-based offset, in characters, from the beginning of the path to the file name in the string pointed to by
/// lpstrFile. For the ANSI version, this is the number of bytes; for the Unicode version, this is the number of
/// characters. For example, if lpstrFile points to the following string, "c:\dir1\dir2\file.ext", this member contains
/// the value 13 to indicate the offset of the "file.ext" string. If the user selects more than one file, nFileOffset is
/// the offset to the first file name.
///
///
public ushort nFileOffset;
///
/// Type: WORD
///
/// The zero-based offset, in characters, from the beginning of the path to the file name extension in the string pointed to by
/// lpstrFile. For the ANSI version, this is the number of bytes; for the Unicode version, this is the number of
/// characters. Usually the file name extension is the substring which follows the last occurrence of the dot (".") character.
/// For example, txt is the extension of the filename readme.txt, html the extension of readme.txt.html. Therefore, if
/// lpstrFile points to the string "c:\dir1\dir2\readme.txt", this member contains the value 20. If lpstrFile
/// points to the string "c:\dir1\dir2\readme.txt.html", this member contains the value 24. If lpstrFile points to the
/// string "c:\dir1\dir2\readme.txt.html.", this member contains the value 29. If lpstrFile points to a string that does
/// not contain any "." character such as "c:\dir1\dir2\readme", this member contains zero.
///
///
public ushort nFileExtension;
///
/// Type: LPCTSTR
///
/// The default extension. GetOpenFileName and GetSaveFileName append this extension to the file name if the user fails to type
/// an extension. This string can be any length, but only the first three characters are appended. The string should not contain
/// a period (.). If this member is NULL and the user fails to type an extension, no extension is appended.
///
///
public StrPtrAuto lpstrDefExt;
///
/// Type: LPARAM
///
/// Application-defined data that the system passes to the hook procedure identified by the lpfnHook member. When the
/// system sends the WM_INITDIALOG message to the hook procedure, the message's lParam parameter is a pointer to the
/// OPENFILENAME structure specified when the dialog box was created. The hook procedure can use this pointer to get the
/// lCustData value.
///
///
public IntPtr lCustData;
///
/// Type: LPOFNHOOKPROC
///
/// A pointer to a hook procedure. This member is ignored unless the Flags member includes the OFN_ENABLEHOOK flag.
///
///
/// If the OFN_EXPLORER flag is not set in the Flags member, lpfnHook is a pointer to an
/// OFNHookProcOldStyle hook procedure that receives messages intended for the dialog box. The hook procedure returns
/// FALSE to pass a message to the default dialog box procedure or TRUE to discard the message.
///
///
/// If OFN_EXPLORER is set, lpfnHook is a pointer to an OFNHookProc hook procedure. The hook procedure receives
/// notification messages sent from the dialog box. The hook procedure also receives messages for any additional controls that
/// you defined by specifying a child dialog template. The hook procedure does not receive messages intended for the standard
/// controls of the default dialog box.
///
///
[MarshalAs(UnmanagedType.FunctionPtr)]
public LPOFNHOOKPROC lpfnHook;
///
/// Type: LPCTSTR
///
/// The name of the dialog template resource in the module identified by the hInstance member. For numbered dialog box
/// resources, this can be a value returned by the MAKEINTRESOURCE macro. This member is ignored unless the
/// OFN_ENABLETEMPLATE flag is set in the Flags member. If the OFN_EXPLORER flag is set, the system uses
/// the specified template to create a dialog box that is a child of the default Explorer-style dialog box. If the
/// OFN_EXPLORER flag is not set, the system uses the template to create an old-style dialog box that replaces the
/// default dialog box.
///
///
[MarshalAs(UnmanagedType.LPTStr)]
public string lpTemplateName;
///
/// Type: void*
/// This member is reserved.
///
private IntPtr pvReserved;
///
/// Type: DWORD
/// This member is reserved.
///
private uint dwReserved;
///
/// Type: DWORD
/// A set of bit flags you can use to initialize the dialog box. Currently, this member can be zero or the following flag.
///
///
/// Value
/// Meaning
///
/// -
/// OFN_EX_NOPLACESBAR 0x00000001
///
/// If this flag is set, the places bar is not displayed. If this flag is not set, Explorer-style dialog boxes include a places
/// bar containing icons for commonly-used folders, such as Favorites and Desktop.
///
///
///
///
public OFN_EX FlagsEx;
}
///
/// Contains information the PageSetupDlg function uses to initialize the Page Setup dialog box. After the user closes the
/// dialog box, the system returns information about the user-defined page parameters in this structure.
///
///
///
/// If the PSD_INHUNDREDTHSOFMILLIMETERS and PSD_INTHOUSANDTHSOFINCHES flags are not specified, the system queries the
/// LOCALE_IMEASURE value of the default user locale to determine the unit of measure (either hundredths of millimeters or
/// thousandths of inches) for the margin widths and paper size.
///
///
/// If both hDevNames and hDevMode have valid handles and the printer name specified by the wDeviceOffset
/// member of the DEVNAMES structure is not the same as the name specified by the dmDeviceName member of the DEVMODE
/// structure, the system uses the name specified by wDeviceOffset by default.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-pagesetupdlga typedef struct tagPSDA { DWORD lStructSize;
// HWND hwndOwner; HGLOBAL hDevMode; HGLOBAL hDevNames; DWORD Flags; POINT ptPaperSize; RECT rtMinMargin; RECT rtMargin; HINSTANCE
// hInstance; LPARAM lCustData; LPPAGESETUPHOOK lpfnPageSetupHook; LPPAGEPAINTHOOK lpfnPagePaintHook; LPCSTR
// lpPageSetupTemplateName; HGLOBAL hPageSetupTemplate; } PAGESETUPDLGA, *LPPAGESETUPDLGA;
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagPSDA")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PAGESETUPDLG
{
///
/// Type: DWORD
/// The size, in bytes, of this structure.
///
public uint lStructSize;
///
/// Type: HWND
///
/// A handle to the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the
/// dialog box has no owner.
///
///
public HWND hwndOwner;
///
/// Type: HGLOBAL
///
/// A handle to a global memory object that contains a DEVMODE structure. On input, if a handle is specified, the values in the
/// corresponding DEVMODE structure are used to initialize the controls in the dialog box. On output, the dialog box sets
/// hDevMode to a global memory handle to a DEVMODE structure that contains values specifying the user's
/// selections. If the user's selections are not available, the dialog box sets hDevMode to NULL.
///
///
public HGLOBAL hDevMode;
///
/// Type: HGLOBAL
///
/// A handle to a global memory object that contains a DEVNAMES structure. This structure contains three strings that specify
/// the driver name, the printer name, and the output port name. On input, if a handle is specified, the strings in the
/// corresponding DEVNAMES structure are used to initialize controls in the dialog box. On output, the dialog box sets
/// hDevNames to a global memory handle to a DEVNAMES structure that contains strings specifying the user's
/// selections. If the user's selections are not available, the dialog box sets hDevNames to NULL.
///
///
public HGLOBAL hDevNames;
///
/// Type: DWORD
///
/// A set of bit flags that you can use to initialize the Page Setup dialog box. When the dialog box returns, it sets
/// these flags to indicate the user's input. This member can be one or more of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// PSD_DEFAULTMINMARGINS 0x00000000
///
/// Sets the minimum values that the user can specify for the page margins to be the minimum margins allowed by the printer.
/// This is the default. This flag is ignored if the PSD_MARGINS and PSD_MINMARGINS flags are also specified.
///
///
/// -
/// PSD_DISABLEMARGINS 0x00000010
/// Disables the margin controls, preventing the user from setting the margins.
///
/// -
/// PSD_DISABLEORIENTATION 0x00000100
/// Disables the orientation controls, preventing the user from setting the page orientation.
///
/// -
/// PSD_DISABLEPAGEPAINTING 0x00080000
///
/// Prevents the dialog box from drawing the contents of the sample page. If you enable a PagePaintHook hook procedure, you can
/// still draw the contents of the sample page.
///
///
/// -
/// PSD_DISABLEPAPER 0x00000200
/// Disables the paper controls, preventing the user from setting page parameters such as the paper size and source.
///
/// -
/// PSD_DISABLEPRINTER 0x00000020
///
/// Obsolete. Windows XP/2000: Disables the Printer button, preventing the user from invoking a dialog box that contains
/// additional printer setup information.
///
///
/// -
/// PSD_ENABLEPAGEPAINTHOOK 0x00040000
/// Enables the hook procedure specified in the lpfnPagePaintHook member.
///
/// -
/// PSD_ENABLEPAGESETUPHOOK 0x00002000
/// Enables the hook procedure specified in the lpfnPageSetupHook member.
///
/// -
/// PSD_ENABLEPAGESETUPTEMPLATE 0x00008000
///
/// Indicates that the hInstance and lpPageSetupTemplateName members specify a dialog box template to use in place of the
/// default template.
///
///
/// -
/// PSD_ENABLEPAGESETUPTEMPLATEHANDLE 0x00020000
///
/// Indicates that the hPageSetupTemplate member identifies a data block that contains a preloaded dialog box template. The
/// system ignores the lpPageSetupTemplateName member if this flag is specified.
///
///
/// -
/// PSD_INHUNDREDTHSOFMILLIMETERS 0x00000008
///
/// Indicates that hundredths of millimeters are the unit of measurement for margins and paper size. The values in the rtMargin,
/// rtMinMargin, and ptPaperSize members are in hundredths of millimeters. You can set this flag on input to override the
/// default unit of measurement for the user's locale. When the function returns, the dialog box sets this flag to indicate the
/// units used.
///
///
/// -
/// PSD_INTHOUSANDTHSOFINCHES 0x00000004
///
/// Indicates that thousandths of inches are the unit of measurement for margins and paper size. The values in the rtMargin,
/// rtMinMargin, and ptPaperSize members are in thousandths of inches. You can set this flag on input to override the default
/// unit of measurement for the user's locale. When the function returns, the dialog box sets this flag to indicate the units used.
///
///
/// -
/// PSD_INWININIINTLMEASURE 0x00000000
/// Reserved.
///
/// -
/// PSD_MARGINS 0x00000002
///
/// Causes the system to use the values specified in the rtMargin member as the initial widths for the left, top, right, and
/// bottom margins. If PSD_MARGINS is not set, the system sets the initial widths to one inch for all margins.
///
///
/// -
/// PSD_MINMARGINS 0x00000001
///
/// Causes the system to use the values specified in the rtMinMargin member as the minimum allowable widths for the left, top,
/// right, and bottom margins. The system prevents the user from entering a width that is less than the specified minimum. If
/// PSD_MINMARGINS is not specified, the system sets the minimum allowable widths to those allowed by the printer.
///
///
/// -
/// PSD_NONETWORKBUTTON 0x00200000
/// Hides and disables the Network button.
///
/// -
/// PSD_NOWARNING 0x00000080
/// Prevents the system from displaying a warning message when there is no default printer.
///
/// -
/// PSD_RETURNDEFAULT 0x00000400
///
/// PageSetupDlg does not display the dialog box. Instead, it sets the hDevNames and hDevMode members to handles to DEVMODE and
/// DEVNAMES structures that are initialized for the system default printer. PageSetupDlg returns an error if either hDevNames
/// or hDevMode is not NULL.
///
///
/// -
/// PSD_SHOWHELP 0x00000800
///
/// Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING
/// registered messages that the dialog box sends when the user clicks the Help button.
///
///
///
///
public PSD Flags;
///
/// Type: POINT
///
/// The dimensions of the paper selected by the user. The PSD_INTHOUSANDTHSOFINCHES or
/// PSD_INHUNDREDTHSOFMILLIMETERS flag indicates the units of measurement.
///
///
public POINT ptPaperSize;
///
/// Type: RECT
///
/// The minimum allowable widths for the left, top, right, and bottom margins. The system ignores this member if the
/// PSD_MINMARGINS flag is not set. These values must be less than or equal to the values specified in the
/// rtMargin member. The PSD_INTHOUSANDTHSOFINCHES or PSD_INHUNDREDTHSOFMILLIMETERS flag indicates the
/// units of measurement.
///
///
public RECT rtMinMargin;
///
/// Type: RECT
///
/// The widths of the left, top, right, and bottom margins. If you set the PSD_MARGINS flag, rtMargin specifies
/// the initial margin values. When PageSetupDlg returns, rtMargin contains the margin widths selected by the user. The
/// PSD_INHUNDREDTHSOFMILLIMETERS or PSD_INTHOUSANDTHSOFINCHES flag indicates the units of measurement.
///
///
public RECT rtMargin;
///
/// Type: HINSTANCE
///
/// If the PSD_ENABLEPAGESETUPTEMPLATE flag is set in the Flags member, hInstance is a handle to the
/// application or module instance that contains the dialog box template named by the lpPageSetupTemplateName member.
///
///
public HINSTANCE hInstance;
///
/// Type: LPARAM
///
/// Application-defined data that the system passes to the hook procedure identified by the lpfnPageSetupHook member.
/// When the system sends the WM_INITDIALOG message to the hook procedure, the message's lParam parameter is a pointer to the
/// PAGESETUPDLG structure specified when the dialog was created. The hook procedure can use this pointer to get the
/// lCustData value.
///
///
public IntPtr lCustData;
///
/// Type: LPPAGESETUPHOOK
///
/// A pointer to a PageSetupHook hook procedure that can process messages intended for the dialog box. This member is ignored
/// unless the PSD_ENABLEPAGESETUPHOOK flag is set in the Flags member.
///
///
[MarshalAs(UnmanagedType.FunctionPtr)]
public LPPAGESETUPHOOK lpfnPageSetupHook;
///
/// Type: LPPAGEPAINTHOOK
///
/// A pointer to a PagePaintHook hook procedure that receives WM_PSD_* messages from the dialog box whenever the sample
/// page is redrawn. By processing the messages, the hook procedure can customize the appearance of the sample page. This member
/// is ignored unless the PSD_ENABLEPAGEPAINTHOOK flag is set in the Flags member.
///
///
[MarshalAs(UnmanagedType.FunctionPtr)]
public LPPAGEPAINTHOOK lpfnPagePaintHook;
///
/// Type: LPCTSTR
///
/// The name of the dialog box template resource in the module identified by the hInstance member. This template is
/// substituted for the standard dialog box template. For numbered dialog box resources, lpPageSetupTemplateName can be a
/// value returned by the MAKEINTRESOURCE macro. This member is ignored unless the PSD_ENABLEPAGESETUPTEMPLATE flag is
/// set in the Flags member.
///
///
[MarshalAs(UnmanagedType.LPTStr)]
public string lpPageSetupTemplateName;
///
/// Type: HGLOBAL
///
/// If the PSD_ENABLEPAGESETUPTEMPLATEHANDLE flag is set in the Flags member, hPageSetupTemplate is a
/// handle to a memory object containing a dialog box template.
///
///
public HGLOBAL hPageSetupTemplate;
}
///
/// Contains information that the PrintDlg function uses to initialize the Print Dialog Box. After the user closes the dialog box,
/// the system uses this structure to return information about the user's selections.
///
///
///
/// If both hDevMode and hDevNames are NULL, PrintDlg initializes the dialog box using the current default
/// printer. To initialize the dialog box for a different printer, use the wDeviceOffset member of the DEVNAMES structure to
/// specify the name of the printer.
///
///
/// Note that the dmDeviceName member of the DEVMODE structure also specifies a printer name. However, dmDeviceName is
/// limited to 32 characters, and the wDeviceOffset name is not. If the wDeviceOffset and dmDeviceName names
/// are not the same, PrintDlg initializes the dialog box using the printer specified by wDeviceOffset.
///
///
/// If the PD_RETURNDEFAULT flag is set and both hDevMode and hDevNames are NULL, PrintDlg uses the
/// hDevNames and hDevMode members to return information about the current default printer without displaying the
/// dialog box.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-printdlga typedef struct tagPDA { DWORD lStructSize; HWND
// hwndOwner; HGLOBAL hDevMode; HGLOBAL hDevNames; HDC hDC; DWORD Flags; WORD nFromPage; WORD nToPage; WORD nMinPage; WORD nMaxPage;
// WORD nCopies; HINSTANCE hInstance; LPARAM lCustData; LPPRINTHOOKPROC lpfnPrintHook; LPSETUPHOOKPROC lpfnSetupHook; LPCSTR
// lpPrintTemplateName; LPCSTR lpSetupTemplateName; HGLOBAL hPrintTemplate; HGLOBAL hSetupTemplate; } PRINTDLGA, *LPPRINTDLGA;
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagPDA")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTDLG
{
///
/// Type: DWORD
/// The structure size, in bytes.
///
public uint lStructSize;
///
/// Type: HWND
///
/// A handle to the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the
/// dialog box has no owner.
///
///
public HWND hwndOwner;
///
/// Type: HGLOBAL
///
/// A handle to a movable global memory object that contains a DEVMODE structure. If hDevMode is not NULL on
/// input, you must allocate a movable block of memory for the DEVMODE structure and initialize its members. The PrintDlg
/// function uses the input data to initialize the controls in the dialog box. When PrintDlg returns, the DEVMODE
/// members indicate the user's input.
///
///
/// If hDevMode is NULL on input, PrintDlg allocates memory for the DEVMODE structure, initializes its members to
/// indicate the user's input, and returns a handle that identifies it.
///
///
/// If the device driver for the specified printer does not support extended device modes, hDevMode is NULL when
/// PrintDlg returns.
///
///
/// If the device name (specified by the dmDeviceName member of the DEVMODE structure) does not appear in the [devices]
/// section of WIN.INI, PrintDlg returns an error.
///
///
/// For more information about the hDevMode and hDevNames members, see the Remarks section at the end of this topic.
///
///
public HGLOBAL hDevMode;
///
/// Type: HGLOBAL
///
/// A handle to a movable global memory object that contains a DEVNAMES structure. If hDevNames is not NULL on
/// input, you must allocate a movable block of memory for the DEVNAMES structure and initialize its members. The
/// PrintDlg function uses the input data to initialize the controls in the dialog box. When PrintDlg returns, the
/// DEVNAMES members contain information for the printer chosen by the user. You can use this information to create a
/// device context or an information context.
///
///
/// The hDevNames member can be NULL, in which case, PrintDlg allocates memory for the DEVNAMES structure,
/// initializes its members to indicate the user's input, and returns a handle that identifies it.
///
///
/// For more information about the hDevMode and hDevNames members, see the Remarks section at the end of this topic.
///
///
public HGLOBAL hDevNames;
///
/// Type: HDC
///
/// A handle to a device context or an information context, depending on whether the Flags member specifies the
/// PD_RETURNDC or PC_RETURNIC flag. If neither flag is specified, the value of this member is undefined. If both
/// flags are specified, PD_RETURNDC has priority.
///
///
public HDC hDC;
///
/// Type: DWORD
///
/// Initializes the Print dialog box. When the dialog box returns, it sets these flags to indicate the user's input. This
/// member can be one or more of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// PD_ALLPAGES 0x00000000
///
/// The default flag that indicates that the All radio button is initially selected. This flag is used as a placeholder to
/// indicate that the PD_PAGENUMS and PD_SELECTION flags are not specified.
///
///
/// -
/// PD_COLLATE 0x00000010
///
/// If this flag is set, the Collate check box is selected. If this flag is set when the PrintDlg function returns, the
/// application must simulate collation of multiple copies. For more information, see the description of the
/// PD_USEDEVMODECOPIESANDCOLLATE flag. See PD_NOPAGENUMS.
///
///
/// -
/// PD_DISABLEPRINTTOFILE 0x00080000
/// Disables the Print to File check box.
///
/// -
/// PD_ENABLEPRINTHOOK 0x00001000
///
/// Enables the hook procedure specified in the lpfnPrintHook member. This enables the hook procedure for the Print dialog box.
///
///
/// -
/// PD_ENABLEPRINTTEMPLATE 0x00004000
///
/// Indicates that the hInstance and lpPrintTemplateName members specify a replacement for the default Print dialog box template.
///
///
/// -
/// PD_ENABLEPRINTTEMPLATEHANDLE 0x00010000
///
/// Indicates that the hPrintTemplate member identifies a data block that contains a preloaded dialog box template. This
/// template replaces the default template for the Print dialog box. The system ignores the lpPrintTemplateName member if this
/// flag is specified.
///
///
/// -
/// PD_ENABLESETUPHOOK 0x00002000
///
/// Enables the hook procedure specified in the lpfnSetupHook member. This enables the hook procedure for the Print Setup dialog box.
///
///
/// -
/// PD_ENABLESETUPTEMPLATE 0x00008000
///
/// Indicates that the hInstance and lpSetupTemplateName members specify a replacement for the default Print Setup dialog box template.
///
///
/// -
/// PD_ENABLESETUPTEMPLATEHANDLE 0x00020000
///
/// Indicates that the hSetupTemplate member identifies a data block that contains a preloaded dialog box template. This
/// template replaces the default template for the Print Setup dialog box. The system ignores the lpSetupTemplateName member if
/// this flag is specified.
///
///
/// -
/// PD_HIDEPRINTTOFILE 0x00100000
/// Hides the Print to File check box.
///
/// -
/// PD_NONETWORKBUTTON 0x00200000
/// Hides and disables the Network button.
///
/// -
/// PD_NOPAGENUMS 0x00000008
///
/// Disables the Pages radio button and the associated edit controls. Also, it causes the Collate check box to appear in the dialog.
///
///
/// -
/// PD_NOSELECTION 0x00000004
/// Disables the Selection radio button.
///
/// -
/// PD_NOWARNING 0x00000080
/// Prevents the warning message from being displayed when there is no default printer.
///
/// -
/// PD_PAGENUMS 0x00000002
///
/// If this flag is set, the Pages radio button is selected. If this flag is set when the PrintDlg function returns, the
/// nFromPage and nToPage members indicate the starting and ending pages specified by the user.
///
///
/// -
/// PD_PRINTSETUP 0x00000040
/// Causes the system to display the Print Setup dialog box rather than the Print dialog box.
///
/// -
/// PD_PRINTTOFILE 0x00000020
///
/// If this flag is set, the Print to File check box is selected. If this flag is set when the PrintDlg function returns, the
/// offset indicated by the wOutputOffset member of the DEVNAMES structure contains the string "FILE:". When you call the
/// StartDoc function to start the printing operation, specify this "FILE:" string in the lpszOutput member of the DOCINFO
/// structure. Specifying this string causes the print subsystem to query the user for the name of the output file.
///
///
/// -
/// PD_RETURNDC 0x00000100
///
/// Causes PrintDlg to return a device context matching the selections the user made in the dialog box. The device context is
/// returned in hDC.
///
///
/// -
/// PD_RETURNDEFAULT 0x00000400
///
/// If this flag is set, the PrintDlg function does not display the dialog box. Instead, it sets the hDevNames and hDevMode
/// members to handles to DEVMODE and DEVNAMES structures that are initialized for the system default printer. Both hDevNames
/// and hDevMode must be NULL, or PrintDlg returns an error.
///
///
/// -
/// PD_RETURNIC 0x00000200
///
/// Similar to the PD_RETURNDC flag, except this flag returns an information context rather than a device context. If neither
/// PD_RETURNDC nor PD_RETURNIC is specified, hDC is undefined on output.
///
///
/// -
/// PD_SELECTION 0x00000001
///
/// If this flag is set, the Selection radio button is selected. If neither PD_PAGENUMS nor PD_SELECTION is set, the All radio
/// button is selected.
///
///
/// -
/// PD_SHOWHELP 0x00000800
///
/// Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING
/// registered messages that the dialog box sends when the user clicks the Help button.
///
///
/// -
/// PD_USEDEVMODECOPIES 0x00040000
/// Same as PD_USEDEVMODECOPIESANDCOLLATE.
///
/// -
/// PD_USEDEVMODECOPIESANDCOLLATE 0x00040000
///
/// This flag indicates whether your application supports multiple copies and collation. Set this flag on input to indicate that
/// your application does not support multiple copies and collation. In this case, the nCopies member of the PRINTDLG structure
/// always returns 1, and PD_COLLATE is never set in the Flags member. If this flag is not set, the application is responsible
/// for printing and collating multiple copies. In this case, the nCopies member of the PRINTDLG structure indicates the number
/// of copies the user wants to print, and the PD_COLLATE flag in the Flags member indicates whether the user wants collation.
/// Regardless of whether this flag is set, an application can determine from nCopies and PD_COLLATE how many copies to render
/// and whether to print them collated. If this flag is set and the printer driver does not support multiple copies, the Copies
/// edit control is disabled. Similarly, if this flag is set and the printer driver does not support collation, the Collate
/// check box is disabled. The dmCopies and dmCollate members of the DEVMODE structure contain the copies and collate
/// information used by the printer driver. If this flag is set and the printer driver supports multiple copies, the dmCopies
/// member indicates the number of copies requested by the user. If this flag is set and the printer driver supports collation,
/// the dmCollate member of the DEVMODE structure indicates whether the user wants collation. If this flag is not set, the
/// dmCopies member always returns 1, and the dmCollate member is always zero. Known issue on Windows 2000/XP/2003: If this flag
/// is not set before calling PrintDlg, PrintDlg might swap nCopies and dmCopies values when it returns. The workaround for this
/// issue is use dmCopies if its value is larger than 1, else, use nCopies, for you to to get the actual number of copies to be
/// printed when PrintDlg returns.
///
///
///
///
/// To ensure that PrintDlg or PrintDlgEx returns the correct values in the dmCopies and dmCollate members of the
/// DEVMODE structure, set PD_RETURNDC = TRUE and PD_USEDEVMODECOPIESANDCOLLATE = TRUE. In so doing,
/// the nCopies member of the PRINTDLG structure is always 1 and PD_COLLATE is always FALSE.
///
///
/// To ensure that PrintDlg or PrintDlgEx returns the correct values in nCopies and PD_COLLATE, set
/// PD_RETURNDC = TRUE and PD_USEDEVMODECOPIESANDCOLLATE = FALSE. In so doing, dmCopies is
/// always 1 and dmCollate is always FALSE.
///
///
/// On Windows Vista and Windows 7, when you call PrintDlg or PrintDlgEx with PD_RETURNDC set to TRUE and
/// PD_USEDEVMODECOPIESANDCOLLATE set to FALSE, the PrintDlg or PrintDlgEx function sets the number
/// of copies in the nCopies member of the PRINTDLG structure, and it sets the number of copies in the structure
/// represented by the hDC member of the PRINTDLG structure.
///
///
/// When making calls to GDI, you must ignore the value of nCopies, consider the value as 1, and use the returned hDC to
/// avoid printing duplicate copies.
///
///
public PD Flags;
///
/// Type: WORD
/// The initial value for the starting page edit control.
///
/// When PrintDlg returns, nFromPage is the starting page specified by the user. If the Pages radio button is
/// selected when the user clicks the Okay button, PrintDlg sets the PD_PAGENUMS flag and does not return
/// until the user enters a starting page value that is within the minimum to maximum page range.
///
///
/// If the input value for either nFromPage or nToPage is outside the minimum/maximum range, PrintDlg returns an
/// error only if the PD_PAGENUMS flag is specified; otherwise, it displays the dialog box but changes the out-of-range
/// value to the minimum or maximum value.
///
///
public ushort nFromPage;
///
/// Type: WORD
///
/// The initial value for the ending page edit control. When PrintDlg returns, nToPage is the ending page specified by
/// the user. If the Pages radio button is selected when the use clicks the Okay button, PrintDlg sets the
/// PD_PAGENUMS flag and does not return until the user enters an ending page value that is within the minimum to maximum
/// page range.
///
///
public ushort nToPage;
///
/// Type: WORD
///
/// The minimum value for the page range specified in the From and To page edit controls. If nMinPage
/// equals nMaxPage, the Pages radio button and the starting and ending page edit controls are disabled.
///
///
public ushort nMinPage;
///
/// Type: WORD
/// The maximum value for the page range specified in the From and To page edit controls.
///
public ushort nMaxPage;
///
/// Type: WORD
///
/// The initial number of copies for the Copies edit control if hDevMode is NULL; otherwise, the
/// dmCopies member of the DEVMODE structure contains the initial value. When PrintDlg returns, nCopies contains
/// the actual number of copies to print. This value depends on whether the application or the printer driver is responsible for
/// printing multiple copies. If the PD_USEDEVMODECOPIESANDCOLLATE flag is set in the Flags member, nCopies
/// is always 1 on return, and the printer driver is responsible for printing multiple copies. If the flag is not set, the
/// application is responsible for printing the number of copies specified by nCopies. For more information, see the
/// description of the PD_USEDEVMODECOPIESANDCOLLATE flag.
///
///
public ushort nCopies;
///
/// Type: HINSTANCE
///
/// If the PD_ENABLEPRINTTEMPLATE or PD_ENABLESETUPTEMPLATE flag is set in the Flags member,
/// hInstance is a handle to the application or module instance that contains the dialog box template named by the
/// lpPrintTemplateName or lpSetupTemplateName member.
///
///
public HINSTANCE hInstance;
///
/// Type: LPARAM
///
/// Application-defined data that the system passes to the hook procedure identified by the lpfnPrintHook or
/// lpfnSetupHook member. When the system sends the WM_INITDIALOG message to the hook procedure, the message's lParam
/// parameter is a pointer to the PRINTDLG structure specified when the dialog was created. The hook procedure can use
/// this pointer to get the lCustData value.
///
///
public IntPtr lCustData;
///
/// Type: LPPRINTHOOKPROC
///
/// A pointer to a PrintHookProc hook procedure that can process messages intended for the Print dialog box. This member
/// is ignored unless the PD_ENABLEPRINTHOOK flag is set in the Flags member.
///
///
[MarshalAs(UnmanagedType.FunctionPtr)]
public LPPRINTHOOKPROC lpfnPrintHook;
///
/// Type: LPSETUPHOOKPROC
///
/// A pointer to a SetupHookProc hook procedure that can process messages intended for the Print Setup dialog box. This
/// member is ignored unless the PD_ENABLESETUPHOOK flag is set in the Flags member.
///
///
[MarshalAs(UnmanagedType.FunctionPtr)]
public LPSETUPHOOKPROC lpfnSetupHook;
///
/// Type: LPCTSTR
///
/// The name of the dialog box template resource in the module identified by the hInstance member. This template replaces
/// the default Print dialog box template. This member is ignored unless the PD_ENABLEPRINTTEMPLATE flag is set in
/// the Flags member.
///
///
[MarshalAs(UnmanagedType.LPTStr)]
public string lpPrintTemplateName;
///
/// Type: LPCTSTR
///
/// The name of the dialog box template resource in the module identified by the hInstance member. This template replaces
/// the default Print Setup dialog box template. This member is ignored unless the PD_ENABLESETUPTEMPLATE flag is
/// set in the Flags member.
///
///
[MarshalAs(UnmanagedType.LPTStr)]
public string lpSetupTemplateName;
///
/// Type: HGLOBAL
///
/// If the PD_ENABLEPRINTTEMPLATEHANDLE flag is set in the Flags member, hPrintTemplate is a handle to a
/// memory object containing a dialog box template. This template replaces the default Print dialog box template.
///
///
public HGLOBAL hPrintTemplate;
///
/// Type: HGLOBAL
///
/// If the PD_ENABLESETUPTEMPLATEHANDLE flag is set in the Flags member, hSetupTemplate is a handle to a
/// memory object containing a dialog box template. This template replaces the default Print Setup dialog box template.
///
///
public HGLOBAL hSetupTemplate;
}
///
/// Contains information that the PrintDlgEx function uses to initialize the Print property sheet. After the user closes the
/// property sheet, the system uses this structure to return information about the user's selections.
///
///
///
/// If both hDevMode and hDevNames are NULL, PrintDlgEx initializes the property sheet using the current
/// default printer. To initialize the property sheet for a different printer, use the wDeviceOffset member of the DEVNAMES
/// structure to specify the name of the printer.
///
///
/// Note that the dmDeviceName member of the DEVMODE structure also specifies a printer name. However, dmDeviceName is
/// limited to 32 characters, and the wDeviceOffset name is not. If the wDeviceOffset and dmDeviceName names
/// are not the same, PrintDlgEx initializes the property sheet using the printer specified by wDeviceOffset.
///
///
/// If the PD_RETURNDEFAULT flag is set and both hDevMode and hDevNames are NULL, PrintDlgEx uses the
/// hDevNames and hDevMode members to return information about the current default printer without displaying the
/// dialog box.
///
///
/// During the execution of PrintDlgEx, the DEVMODE and DEVNAMES structures that you specified in the PRINTDLGEX
/// structure may not always contain current data. For this reason, application-specific property pages as well as
/// IPrintDialogCallback routines for the initial page should use the IPrintDialogServices interface to retrieve information about
/// the state of the current printer.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-printdlgexa typedef struct tagPDEXA { DWORD lStructSize;
// HWND hwndOwner; HGLOBAL hDevMode; HGLOBAL hDevNames; HDC hDC; DWORD Flags; DWORD Flags2; DWORD ExclusionFlags; DWORD nPageRanges;
// DWORD nMaxPageRanges; LPPRINTPAGERANGE lpPageRanges; DWORD nMinPage; DWORD nMaxPage; DWORD nCopies; HINSTANCE hInstance; LPCSTR
// lpPrintTemplateName; LPUNKNOWN lpCallback; DWORD nPropertyPages; HPROPSHEETPAGE *lphPropertyPages; DWORD nStartPage; DWORD
// dwResultAction; } PRINTDLGEXA, *LPPRINTDLGEXA;
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagPDEXA")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTDLGEX
{
///
/// Type: DWORD
/// The structure size, in bytes.
///
public uint lStructSize;
///
/// Type: HWND
/// A handle to the window that owns the property sheet. This member must be a valid window handle; it cannot be NULL.
///
public HWND hwndOwner;
///
/// Type: HGLOBAL
///
/// A handle to a movable global memory object that contains a DEVMODE structure. If hDevMode is not NULL on
/// input, you must allocate a movable block of memory for the DEVMODE structure and initialize its members. The
/// PrintDlgEx function uses the input data to initialize the controls in the property sheet. When PrintDlgEx returns,
/// the DEVMODE members indicate the user's input.
///
///
/// If hDevMode is NULL on input, PrintDlgEx allocates memory for the DEVMODE structure, initializes its members
/// to indicate the user's input, and returns a handle that identifies it.
///
///
/// For more information about the hDevMode and hDevNames members, see the Remarks section at the end of this topic.
///
///
public HGLOBAL hDevMode;
///
/// Type: HGLOBAL
///
/// A handle to a movable global memory object that contains a DEVNAMES structure. If hDevNames is not NULL on
/// input, you must allocate a movable block of memory for the DEVNAMES structure and initialize its members. The
/// PrintDlgEx function uses the input data to initialize the controls in the property sheet. When PrintDlgEx returns,
/// the DEVNAMES members contain information for the printer chosen by the user. You can use this information to create a
/// device context or an information context.
///
///
/// The hDevNames member can be NULL, in which case, PrintDlgEx allocates memory for the DEVNAMES structure,
/// initializes its members to indicate the user's input, and returns a handle that identifies it.
///
///
/// For more information about the hDevMode and hDevNames members, see the Remarks section at the end of this topic.
///
///
public HGLOBAL hDevNames;
///
/// Type: HDC
///
/// A handle to a device context or an information context, depending on whether the Flags member specifies the
/// PD_RETURNDC or PC_RETURNIC flag. If neither flag is specified, the value of this member is undefined. If both
/// flags are specified, PD_RETURNDC has priority.
///
///
public HDC hDC;
///
/// Type: DWORD
///
/// A set of bit flags that you can use to initialize the Print property sheet. When the PrintDlgEx function returns, it
/// sets these flags to indicate the user's input. This member can be one or more of the following values.
///
///
/// To ensure that PrintDlg or PrintDlgEx returns the correct values in the dmCopies and dmCollate members of the
/// DEVMODE structure, set PD_RETURNDC = TRUE and PD_USEDEVMODECOPIESANDCOLLATE = TRUE. In so doing,
/// the nCopies member of the PRINTDLG structure is always 1 and PD_COLLATE is always FALSE.
///
///
/// To ensure that PrintDlg or PrintDlgEx returns the correct values in nCopies and PD_COLLATE, set
/// PD_RETURNDC = TRUE and PD_USEDEVMODECOPIESANDCOLLATE = FALSE. In so doing, dmCopies is
/// always 1 and dmCollate is always FALSE.
///
///
/// Starting with Windows Vista, when you call PrintDlg or PrintDlgEx with PD_RETURNDC set to TRUE and
/// PD_USEDEVMODECOPIESANDCOLLATE set to FALSE, the PrintDlg or PrintDlgEx function sets the number
/// of copies in the nCopies member of the PRINTDLG structure, and it sets the number of copies in the structure
/// represented by the hDC member of the PRINTDLG structure.
///
///
/// When making calls to GDI, you must ignore the value of nCopies, consider the value as 1, and use the returned
/// hDC to avoid printing duplicate copies.
///
///
///
/// Value
/// Meaning
///
/// -
/// PD_ALLPAGES 0x00000000
///
/// The default flag that indicates that the All radio button is initially selected. This flag is used as a placeholder to
/// indicate that the PD_PAGENUMS, PD_SELECTION, and PD_CURRENTPAGE flags are not specified.
///
///
/// -
/// PD_COLLATE 0x00000010
///
/// If this flag is set, the Collate check box is selected. If this flag is set when the PrintDlgEx function returns, the
/// application must simulate collation of multiple copies. For more information, see the description of the
/// PD_USEDEVMODECOPIESANDCOLLATE flag. See PD_NOPAGENUMS.
///
///
/// -
/// PD_CURRENTPAGE 0x00400000
///
/// If this flag is set, the Current Page radio button is selected. If none of the PD_PAGENUMS, PD_SELECTION, or PD_CURRENTPAGE
/// flags is set, the All radio button is selected.
///
///
/// -
/// PD_DISABLEPRINTTOFILE 0x00080000
/// Disables the Print to File check box.
///
/// -
/// PD_ENABLEPRINTTEMPLATE 0x00004000
///
/// Indicates that the hInstance and lpPrintTemplateName members specify a replacement for the default dialog box template in
/// the lower portion of the General page. The default template contains controls similar to those of the Print dialog box. The
/// system uses the specified template to create a window that is a child of the General page.
///
///
/// -
/// PD_ENABLEPRINTTEMPLATEHANDLE 0x00010000
///
/// Indicates that the hInstance member identifies a data block that contains a preloaded dialog box template. This template
/// replaces the default dialog box template in the lower portion of the General page. The system uses the specified template to
/// create a window that is a child of the General page. The system ignores the lpPrintTemplateName member if this flag is specified.
///
///
/// -
/// PD_EXCLUSIONFLAGS 0x01000000
///
/// Indicates that the ExclusionFlags member identifies items to be excluded from the printer driver property pages. If this
/// flag is not set, items will be excluded by default from the printer driver property pages. The exclusions prevent the
/// duplication of items among the General page, any application-specified pages, and the printer driver pages.
///
///
/// -
/// PD_HIDEPRINTTOFILE 0x00100000
/// Hides the Print to File check box.
///
/// -
/// PD_NOCURRENTPAGE 0x00800000
/// Disables the Current Page radio button.
///
/// -
/// PD_NOPAGENUMS 0x00000008
///
/// Disables the Pages radio button and the associated edit controls. Also, it causes the Collate check box to appear in the dialog.
///
///
/// -
/// PD_NOSELECTION 0x00000004
/// Disables the Selection radio button.
///
/// -
/// PD_NOWARNING 0x00000080
/// Prevents the warning message from being displayed when an error occurs.
///
/// -
/// PD_PAGENUMS 0x00000002
///
/// If this flag is set, the Pages radio button is selected. If none of the PD_PAGENUMS, PD_SELECTION, or PD_CURRENTPAGE flags
/// is set, the All radio button is selected. If this flag is set when the PrintDlgEx function returns, the lpPageRanges member
/// indicates the page ranges specified by the user.
///
///
/// -
/// PD_PRINTTOFILE 0x00000020
///
/// If this flag is set, the Print to File check box is selected. If this flag is set when PrintDlgEx returns, the offset
/// indicated by the wOutputOffset member of the DEVNAMES structure contains the string "FILE:". When you call the StartDoc
/// function to start the printing operation, specify this "FILE:" string in the lpszOutput member of the DOCINFO structure.
/// Specifying this string causes the print subsystem to query the user for the name of the output file.
///
///
/// -
/// PD_RETURNDC 0x00000100
///
/// Causes PrintDlgEx to return a device context matching the selections the user made in the property sheet. The device context
/// is returned in hDC.
///
///
/// -
/// PD_RETURNDEFAULT 0x00000400
///
/// If this flag is set, the PrintDlgEx function does not display the property sheet. Instead, it sets the hDevNames and
/// hDevMode members to handles to DEVNAMES and DEVMODE structures that are initialized for the system default printer. Both
/// hDevNames and hDevMode must be NULL, or PrintDlgEx returns an error.
///
///
/// -
/// PD_RETURNIC 0x00000200
///
/// Similar to the PD_RETURNDC flag, except this flag returns an information context rather than a device context. If neither
/// PD_RETURNDC nor PD_RETURNIC is specified, hDC is undefined on output.
///
///
/// -
/// PD_SELECTION 0x00000001
///
/// If this flag is set, the Selection radio button is selected. If none of the PD_PAGENUMS, PD_SELECTION, or PD_CURRENTPAGE
/// flags is set, the All radio button is selected.
///
///
/// -
/// PD_USEDEVMODECOPIES 0x00040000
/// Same as PD_USEDEVMODECOPIESANDCOLLATE.
///
/// -
/// PD_USEDEVMODECOPIESANDCOLLATE 0x00040000
///
/// This flag indicates whether your application supports multiple copies and collation. Set this flag on input to indicate that
/// your application does not support multiple copies and collation. In this case, the nCopies member of the PRINTDLGEX
/// structure always returns 1, and PD_COLLATE is never set in the Flags member. If this flag is not set, the application is
/// responsible for printing and collating multiple copies. In this case, the nCopies member of the PRINTDLGEX structure
/// indicates the number of copies the user wants to print, and the PD_COLLATE flag in the Flags member indicates whether the
/// user wants collation. Regardless of whether this flag is set, an application can determine from nCopies and PD_COLLATE how
/// many copies to render and whether to print them collated. If this flag is set and the printer driver does not support
/// multiple copies, the Copies edit control is disabled. Similarly, if this flag is set and the printer driver does not support
/// collation, the Collate check box is disabled. The dmCopies and dmCollate members of the DEVMODE structure contain the copies
/// and collate information used by the printer driver. If this flag is set and the printer driver supports multiple copies, the
/// dmCopies member indicates the number of copies requested by the user. If this flag is set and the printer driver supports
/// collation, the dmCollate member of the DEVMODE structure indicates whether the user wants collation. If this flag is not
/// set, the dmCopies member always returns 1, and the dmCollate member is always zero. In Windows versions prior to Windows
/// Vista, if this flag is not set by the calling application and the dmCopies member of the DEVMODE structure is greater than
/// 1, use that value for the number of copies; otherwise, use the value of the nCopies member of the PRINTDLGEX structure.
///
///
/// -
/// PD_USELARGETEMPLATE 0x10000000
///
/// Forces the property sheet to use a large template for the General page. The larger template provides more space for
/// applications that specify a custom template for the lower portion of the General page.
///
///
///
///
public PD Flags;
/// Type: DWORD
public uint Flags2;
///
/// Type: DWORD
///
/// A set of bit flags that can exclude items from the printer driver property pages in the Print property sheet. This
/// value is used only if the PD_EXCLUSIONFLAGS flag is set in the Flags member. Exclusion flags should be used
/// only if the item to be excluded will be included on either the General page or on an application-defined page in the
/// Print property sheet. This member can specify the following flag.
///
/// PD_EXCL_COPIESANDCOLLATE
///
/// Excludes the Copies and Collate controls from the printer driver property pages in a Print property
/// sheet. This flag should always be set when the application uses the default Copies and Collate controls
/// provided by the lower portion of the General page of the Print property sheet.
///
///
public PD_EXCL ExclusionFlags;
///
/// Type: DWORD
///
/// On input, set this member to the initial number of page ranges specified in the lpPageRanges array. When the
/// PrintDlgEx function returns, nPageRanges indicates the number of user-specified page ranges stored in the
/// lpPageRanges array. If the PD_NOPAGENUMS flag is specified, this value is not valid.
///
///
public uint nPageRanges;
///
/// Type: DWORD
///
/// The size, in array elements, of the lpPageRanges buffer. This value indicates the maximum number of page ranges that
/// can be stored in the array. If the PD_NOPAGENUMS flag is specified, this value is not valid. If the
/// PD_NOPAGENUMS flag is not specified, this value must be greater than zero.
///
///
public uint nMaxPageRanges;
///
/// Type: LPPRINTPAGERANGE
///
/// Pointer to a buffer containing an array of PRINTPAGERANGE structures. On input, the array contains the initial page ranges
/// to display in the Pages edit control. When the PrintDlgEx function returns, the array contains the page ranges
/// specified by the user. If the PD_NOPAGENUMS flag is specified, this value is not valid. If the PD_NOPAGENUMS
/// flag is not specified, lpPageRanges must be non- NULL.
///
///
public IntPtr lpPageRanges;
///
/// Type: DWORD
///
/// The minimum value for the page ranges specified in the Pages edit control. If the PD_NOPAGENUMS flag is
/// specified, this value is not valid.
///
///
public uint nMinPage;
///
/// Type: DWORD
///
/// The maximum value for the page ranges specified in the Pages edit control. If the PD_NOPAGENUMS flag is
/// specified, this value is not valid.
///
///
public uint nMaxPage;
///
/// Type: DWORD
///
/// Contains the initial number of copies for the Copies edit control if hDevMode is NULL; otherwise, the
/// dmCopies member of the DEVMODE structure contains the initial value. When PrintDlgEx returns, nCopies contains
/// the actual number of copies the application must print. This value depends on whether the application or the printer driver
/// is responsible for printing multiple copies. If the PD_USEDEVMODECOPIESANDCOLLATE flag is set in the Flags
/// member, nCopies is always 1 on return, and the printer driver is responsible for printing multiple copies. If the
/// flag is not set, the application is responsible for printing the number of copies specified by nCopies. For more
/// information, see the description of the PD_USEDEVMODECOPIESANDCOLLATE flag.
///
///
public uint nCopies;
///
/// Type: HINSTANCE
///
/// If the PD_ENABLEPRINTTEMPLATE flag is set in the Flags member, hInstance is a handle to the application
/// or module instance that contains the dialog box template named by the lpPrintTemplateName member. If the
/// PD_ENABLEPRINTTEMPLATEHANDLE flag is set in the Flags member, hInstance is a handle to a memory object
/// containing a dialog box template. If neither of the template flags is set in the Flags member, hInstance
/// should be NULL.
///
///
public HINSTANCE hInstance;
///
/// Type: LPCTSTR
///
/// The name of the dialog box template resource in the module identified by the hInstance member. This template replaces
/// the default dialog box template in the lower portion of the General page. The default template contains controls
/// similar to those of the Print dialog box. This member is ignored unless the PD_ENABLEPRINTTEMPLATE flag is set in the
/// Flags member.
///
///
[MarshalAs(UnmanagedType.LPTStr)]
public string lpPrintTemplateName;
///
/// Type: LPUNKNOWN
/// A pointer to an application-defined callback object.
///
/// The object should contain the IPrintDialogCallback class to receive messages for the child dialog box in the lower portion
/// of the General page.
///
///
/// The callback object should also contain the IObjectWithSite class to receive a pointer to the IPrintDialogServices
/// interface. The PrintDlgEx function calls IUnknown::QueryInterface on the callback object for both
/// IID_IPrintDialogCallback and IID_IObjectWithSite to determine which interfaces are supported.
///
/// If you do not want to retrieve any of the callback information, set lpCallback to NULL.
///
[MarshalAs(UnmanagedType.IUnknown)]
public object lpCallback;
///
/// Type: DWORD
/// The number of property page handles in the lphPropertyPages array.
///
public uint nPropertyPages;
///
/// Type: HPROPSHEETPAGE*
///
/// Contains an array of property page handles to add to the Print property sheet. The additional property pages follow
/// the General page. Use the CreatePropertySheetPage function to create these additional pages. When the PrintDlgEx
/// function returns, all the HPROPSHEETPAGE handles in the lphPropertyPages array have been destroyed. If
/// nPropertyPages is zero, lphPropertyPages should be NULL.
///
///
public IntPtr lphPropertyPages;
///
/// Type: DWORD
///
/// The property page that is initially displayed. To display the General page, specify START_PAGE_GENERAL.
/// Otherwise, specify the zero-based index of a property page in the array specified in the lphPropertyPages member. For
/// consistency, it is recommended that the property sheet always be started on the General page.
///
///
public uint nStartPage;
///
/// Type: DWORD
///
/// On input, set this member to zero. If the PrintDlgEx function returns S_OK, dwResultAction contains the outcome of
/// the dialog. If PrintDlgEx returns an error, this member should be ignored. The dwResultAction member can be
/// one of the following values.
///
/// PD_RESULT_APPLY
///
/// The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to
/// apply the changes made in the property sheet, but does not want to print yet. The PRINTDLGEX structure contains the
/// information specified by the user at the time the Apply button was clicked.
///
/// PD_RESULT_CANCEL
/// The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged.
/// PD_RESULT_PRINT
///
/// The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user.
///
///
public PD_RESULT dwResultAction;
}
///
/// Represents a range of pages in a print job. A print job can have more than one page range. This information is supplied in the
/// PRINTDLGEX structure when calling the PrintDlgEx function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-printpagerange typedef struct tagPRINTPAGERANGE { DWORD
// nFromPage; DWORD nToPage; } PRINTPAGERANGE;
[PInvokeData("commdlg.h", MSDNShortId = "NS:commdlg.tagPRINTPAGERANGE")]
[StructLayout(LayoutKind.Sequential)]
public struct PRINTPAGERANGE
{
///
/// Type: DWORD
/// The first page of the range.
///
public uint nFromPage;
///
/// Type: DWORD
/// The last page of the range.
///
public uint nToPage;
}
}
}