diff --git a/PInvoke/ComDlg32/ComDlg32.Funcs.cs b/PInvoke/ComDlg32/ComDlg32.Funcs.cs
new file mode 100644
index 00000000..ed401fbe
--- /dev/null
+++ b/PInvoke/ComDlg32/ComDlg32.Funcs.cs
@@ -0,0 +1,1571 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the ComDlg32.dll
+ public static partial class ComDlg32
+ {
+ private const string Lib_ComDlg32 = "ComDlg32.dll";
+
+ ///
+ /// A Color dialog box sends the COLOROKSTRING registered message to your hook procedure, CCHookProc, when the user selects a color
+ /// and clicks the OK button. The hook procedure can accept the color and allow the dialog box to close, or reject the color and
+ /// force the dialog box to remain open.
+ ///
+ public const string COLOROKSTRING = "commdlg_ColorOK";
+
+ ///
+ /// An Open or Save As dialog box sends the FILEOKSTRING registered message to your hook procedure, OFNHookProc, when the user
+ /// specifies a file name and clicks the OK button. The hook procedure can accept the file name and allow the dialog box to close,
+ /// or reject the file name and force the dialog box to remain open.
+ ///
+ public const string FILEOKSTRING = "commdlg_FileNameOK";
+
+ ///
+ /// A Find or Replace dialog box sends the FINDMSGSTRING registered message to the window procedure of its owner window when the
+ /// user clicks the Find Next, Replace, or Replace All button, or closes the dialog box.
+ ///
+ public const string FINDMSGSTRING = "commdlg_FindReplace";
+
+ ///
+ /// A common dialog box sends the HELPMSGSTRING registered message to the window procedure of its owner window when the user clicks
+ /// the Help button.
+ ///
+ public const string HELPMSGSTRING = "commdlg_help";
+
+ ///
+ /// An Open or Save As dialog box sends the LBSELCHSTRING registered message to your hook procedure when the selection changes in
+ /// any of the list boxes or combo boxes of the dialog box.
+ ///
+ public const string LBSELCHSTRING = "commdlg_LBSelChangedNotify";
+
+ ///
+ /// The hook procedure of a Color dialog box, CCHookProc, can send the SETRGBSTRING registered message to the dialog box to set the
+ /// current color selection.
+ ///
+ public const string SETRGBSTRING = "commdlg_SetRGBColor";
+
+ ///
+ /// An Open or Save As dialog box sends the SHAREVISTRING registered message to your hook procedure, OFNHookProc, if a sharing
+ /// violation occurs for the selected file when the user clicks the OK button.
+ ///
+ public const string SHAREVISTRING = "commdlg_ShareViolation";
+
+ ///
+ ///
+ /// Receives messages or notifications intended for the default dialog box procedure of the Color dialog box. This is an
+ /// application-defined or library-defined callback function that is used with the ChooseColor function.
+ ///
+ ///
+ /// The LPCCHOOKPROC type defines a pointer to this callback function. CCHookProc is a placeholder for the
+ /// application-defined function name.
+ ///
+ ///
+ /// A handle to the Color dialog box for which the message is intended.
+ /// The identifier of the message being received.
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ ///
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter. If the Arg2 parameter
+ /// indicates the WM_INITDIALOG message, then Arg4 is a pointer to a CHOOSECOLOR structure containing the values specified when the
+ /// dialog was created.
+ ///
+ ///
+ /// If the hook procedure returns zero, the default dialog box procedure processes the message.
+ /// If the hook procedure returns a nonzero value, the default dialog box procedure ignores the message.
+ ///
+ ///
+ ///
+ /// When you use the ChooseColor function to create a Color dialog box, you can provide a CCHookProc hook procedure to
+ /// process messages or notifications intended for the dialog box procedure. To enable the hook procedure, use the CHOOSECOLOR
+ /// structure that you passed to the dialog creation function. Specify the address of the hook procedure in the lpfnHook
+ /// member and specify the CC_ENABLEHOOK flag in the Flags member.
+ ///
+ ///
+ /// The default dialog box procedure processes the WM_INITDIALOG message before passing it to the hook procedure. For all other
+ /// messages, the hook procedure receives the message first. Then, the return value of the hook procedure determines whether the
+ /// default dialog procedure processes the message or ignores it.
+ ///
+ ///
+ /// If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid brush handle to painting the background of
+ /// the dialog box. In general, if the hook procedure processes any WM_CTLCOLOR* message, it must return a valid brush handle
+ /// to painting the background of the specified control.
+ ///
+ ///
+ /// Do not call the EndDialog function from the hook procedure. Instead, the hook procedure can call the PostMessage function to
+ /// post a WM_COMMAND message with the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog
+ /// box and causes the dialog box function to return FALSE. If you need to know why the hook procedure closed the dialog box,
+ /// you must provide your own communication mechanism between the hook procedure and your application.
+ ///
+ ///
+ /// You can subclass the standard controls of a common dialog box. However, the dialog box procedure may also subclass the controls.
+ /// Because of this, you should subclass controls when your hook procedure processes the WM_INITDIALOG message. This ensures that
+ /// your subclass procedure receives the control-specific messages before the subclass procedure set by the dialog box procedure.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nc-commdlg-lpcchookproc LPCCHOOKPROC Lpcchookproc; UINT_PTR
+ // Lpcchookproc( HWND Arg1, UINT Arg2, WPARAM Arg3, LPARAM Arg4 ) {...}
+ [PInvokeData("commdlg.h", MSDNShortId = "NC:commdlg.LPCCHOOKPROC")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate IntPtr LPCCHOOKPROC(HWND Arg1, uint Arg2, IntPtr Arg3, IntPtr Arg4);
+
+ ///
+ ///
+ /// Receives messages or notifications intended for the default dialog box procedure of the Font dialog box. This is an
+ /// application-defined or library-defined callback procedure that is used with the ChooseFont function.
+ ///
+ ///
+ /// The LPCFHOOKPROC type defines a pointer to this callback function. CFHookProc is a placeholder for the
+ /// application-defined function name.
+ ///
+ ///
+ /// A handle to the Font dialog box for which the message is intended.
+ /// The identifier of the message being received.
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ ///
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter. If the Arg2 parameter
+ /// indicates the WM_INITDIALOG message, Arg4 is a pointer to a CHOOSEFONT structure containing the values specified when the dialog
+ /// box was created.
+ ///
+ ///
+ /// If the hook procedure returns zero, the default dialog box procedure processes the message.
+ /// If the hook procedure returns a nonzero value, the default dialog box procedure ignores the message.
+ ///
+ ///
+ ///
+ /// When you use the ChooseFont function to create a Font dialog box, you can provide a CFHookProc hook procedure to process
+ /// messages or notifications intended for the dialog box procedure. To enable the hook procedure, use the CHOOSEFONT
+ /// structure that you passed to the dialog creation function. Specify the address of the hook procedure in the lpfnHook
+ /// member and specify the CF_ENABLEHOOK flag in the Flags member.
+ ///
+ ///
+ /// The default dialog box procedure processes the WM_INITDIALOG message before passing it to the hook procedure. For all other
+ /// messages, the hook procedure receives the message first. The return value of the hook procedure determines whether the default
+ /// dialog box procedure processes the message or ignores it.
+ ///
+ ///
+ /// If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid brush handle to paint the background of the
+ /// dialog box. In general, if the hook procedure processes any WM_CTLCOLOR* message, it must return a valid brush handle to
+ /// paint the background of the specified control.
+ ///
+ ///
+ /// Do not call the EndDialog function from the hook procedure. Instead, the hook procedure can call the PostMessage function to
+ /// post a WM_COMMAND message with the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog
+ /// box and causes the dialog box function to return FALSE. If you need to know why the hook procedure closed the dialog box,
+ /// you must provide your own communication mechanism between the hook procedure and your application.
+ ///
+ ///
+ /// You can subclass the standard controls of a common dialog box. However, the dialog box procedure may also subclass the controls.
+ /// Because of this, you should subclass controls when your hook procedure processes the WM_INITDIALOG message. This ensures that
+ /// your subclass procedure receives the control-specific messages before the subclass procedure set by the dialog box procedure.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nc-commdlg-lpcfhookproc LPCFHOOKPROC Lpcfhookproc; UINT_PTR
+ // Lpcfhookproc( HWND Arg1, UINT Arg2, WPARAM Arg3, LPARAM Arg4 ) {...}
+ [PInvokeData("commdlg.h", MSDNShortId = "NC:commdlg.LPCFHOOKPROC")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate IntPtr LPCFHOOKPROC(HWND Arg1, uint Arg2, IntPtr Arg3, IntPtr Arg4);
+
+ ///
+ ///
+ /// Receives messages or notifications intended for the default dialog box procedure of the Find or Replace dialog
+ /// box. The FRHookProc hook procedure is an application-defined or library-defined callback function that is used with the FindText
+ /// or ReplaceText function.
+ ///
+ ///
+ /// The LPFRHOOKPROC type defines a pointer to this callback function. FRHookProc is a placeholder for the
+ /// application-defined function name.
+ ///
+ ///
+ /// A handle to the Find or Replace dialog box for which the message is intended.
+ /// The identifier of the message being received.
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ ///
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ ///
+ /// If the Arg2 parameter indicates the WM_INITDIALOG message, Arg4 is a pointer to a FINDREPLACE structure containing the values
+ /// specified when the dialog box was created.
+ ///
+ ///
+ ///
+ /// If the hook procedure returns zero, the default dialog box procedure processes the message.
+ /// If the hook procedure returns a nonzero value, the default dialog box procedure ignores the message.
+ ///
+ ///
+ ///
+ /// When you use the FindText or ReplaceText functions to create a Find or Replace dialog box, you can provide an
+ /// FRHookProc hook procedure to process messages or notifications intended for the dialog box procedure. To enable the hook
+ /// procedure, use the FINDREPLACE structure that you passed to the dialog creation function. Specify the address of the hook
+ /// procedure in the lpfnHook member and specify the FR_ENABLEHOOK flag in the Flags member.
+ ///
+ ///
+ /// The default dialog box procedure processes the WM_INITDIALOG message before passing it to the hook procedure. For all other
+ /// messages, the hook procedure receives the message first. Then, the return value of the hook procedure determines whether the
+ /// default dialog procedure processes the message or ignores it.
+ ///
+ ///
+ /// If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid brush handle for painting the background of
+ /// the dialog box. In general, if the hook procedure processes any WM_CTLCOLOR* message, it must return a valid brush handle
+ /// for painting the background of the specified control.
+ ///
+ ///
+ /// Do not call the EndDialog function from the hook procedure. Instead, the hook procedure can call the PostMessage function to
+ /// post a WM_COMMAND message with the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog
+ /// box and causes the dialog box function to return FALSE. If you need to know why the hook procedure closed the dialog box,
+ /// you must provide your own communication mechanism between the hook procedure and your application.
+ ///
+ ///
+ /// You can subclass the standard controls of a common dialog box. However, the dialog box procedure may also subclass the controls.
+ /// Because of this, you should subclass controls when your hook procedure processes the WM_INITDIALOG message. This ensures that
+ /// your subclass procedure receives the control-specific messages before the subclass procedure set by the dialog box procedure.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nc-commdlg-lpfrhookproc LPFRHOOKPROC Lpfrhookproc; UINT_PTR
+ // Lpfrhookproc( HWND Arg1, UINT Arg2, WPARAM Arg3, LPARAM Arg4 ) {...}
+ [PInvokeData("commdlg.h", MSDNShortId = "NC:commdlg.LPFRHOOKPROC")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate IntPtr LPFRHOOKPROC(HWND Arg1, uint Arg2, IntPtr Arg3, IntPtr Arg4);
+
+ ///
+ ///
+ /// [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.]
+ ///
+ ///
+ /// Receives notification messages sent from the dialog box. The function also receives messages for any additional controls that
+ /// you defined by specifying a child dialog template. The OFNHookProc hook procedure is an application-defined or library-defined
+ /// callback function that is used with the Explorer-style Open and Save As dialog boxes.
+ ///
+ ///
+ /// The LPOFNHOOKPROC type defines a pointer to this callback function. OFNHookProc is a placeholder for the
+ /// application-defined function name.
+ ///
+ ///
+ ///
+ /// A handle to the child dialog box of the Open or Save As dialog box. Use the GetParent function to get the handle
+ /// to the Open or Save As dialog box.
+ ///
+ /// The identifier of the message being received.
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ ///
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter. If the Arg2 parameter
+ /// indicates the WM_INITDIALOG message, Arg4 is a pointer to an OPENFILENAME structure containing the values specified when the
+ /// dialog box was created.
+ ///
+ ///
+ /// If the hook procedure returns zero, the default dialog box procedure processes the message.
+ /// If the hook procedure returns a nonzero value, the default dialog box procedure ignores the message.
+ ///
+ /// For the CDN_SHAREVIOLATION and CDN_FILEOK notification messages, the hook procedure should return a nonzero value to indicate
+ /// that it has used the SetWindowLong function to set a nonzero DWL_MSGRESULT value.
+ ///
+ ///
+ ///
+ ///
+ /// If you do not specify the OFN_EXPLORER flag when you create an Open or Save As dialog box, and you want a
+ /// hook procedure, you must use an old-style OFNHookProcOldStyle hook procedure. In this case, the dialog box will have the
+ /// old-style user interface.
+ ///
+ ///
+ /// When you use the GetOpenFileName or GetSaveFileName functions to create an Explorer-style Open or Save As dialog
+ /// box, you can provide an OFNHookProc hook procedure. To enable the hook procedure, use the OPENFILENAME structure that you passed
+ /// to the dialog creation function. Specify the pointer to the hook procedure in the lpfnHook member and specify the
+ /// OFN_ENABLEHOOK flag in the Flags member.
+ ///
+ ///
+ /// If you provide a hook procedure for an Explorer-style common dialog box, the system creates a dialog box that is a child of the
+ /// default dialog box. The hook procedure acts as the dialog procedure for the child dialog. This child dialog is based on the
+ /// template you specified in the OPENFILENAME structure, or it is a default child dialog if no template is specified. The child
+ /// dialog is created when the default dialog procedure is processing its WM_INITDIALOG message. After the child dialog processes
+ /// its own WM_INITDIALOG message, the default dialog procedure moves the standard controls, if necessary, to make room for
+ /// any additional controls of the child dialog. The system then sends the CDN_INITDONE notification message to the hook procedure.
+ ///
+ ///
+ /// The hook procedure does not receive messages intended for the standard controls of the default dialog box. You can subclass the
+ /// standard controls, but this is discouraged because it may make your application incompatible with later versions. However, the
+ /// Explorer-style common dialog boxes provide a set of messages that the hook procedure can use to monitor and control the dialog.
+ /// These include a set of notification messages sent from the dialog, as well as messages that you can send to retrieve information
+ /// from the dialog. For a complete list of these messages, see Explorer-Style Hook Procedures.
+ ///
+ ///
+ /// If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid brush handle to painting the background of
+ /// the dialog box. In general, if it processes any WM_CTLCOLOR* message, it must return a valid brush handle to painting the
+ /// background of the specified control.
+ ///
+ ///
+ /// Do not call the EndDialog function from the hook procedure. Instead, the hook procedure can call the PostMessage function to
+ /// post a WM_COMMAND message with the IDCANCEL value to the dialog box procedure. Posting IDCANCEL closes the dialog
+ /// box and causes the dialog box function to return FALSE. If you need to know why the hook procedure closed the dialog box,
+ /// you must provide your own communication mechanism between the hook procedure and your application.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nc-commdlg-lpofnhookproc LPOFNHOOKPROC Lpofnhookproc; UINT_PTR
+ // Lpofnhookproc( HWND Arg1, UINT Arg2, WPARAM Arg3, LPARAM Arg4 ) {...}
+ [PInvokeData("commdlg.h", MSDNShortId = "NC:commdlg.LPOFNHOOKPROC")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate IntPtr LPOFNHOOKPROC(HWND Arg1, uint Arg2, IntPtr Arg3, IntPtr Arg4);
+
+ ///
+ ///
+ /// Receives messages that allow you to customize drawing of the sample page in the Page Setup dialog box. The PagePaintHook
+ /// hook procedure is an application-defined or library-defined callback function used with the PageSetupDlg function.
+ ///
+ ///
+ /// The LPPAGEPAINTHOOK type defines a pointer to this callback function. PagePaintHook is a placeholder for the
+ /// application-defined or library-defined function name.
+ ///
+ ///
+ /// A handle to the Page Setup dialog box.
+ /// The identifier of the message being received.
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ ///
+ ///
+ /// If the hook procedure returns TRUE for any of the first three messages of a drawing sequence (WM_PSD_PAGESETUPDLG,
+ /// WM_PSD_FULLPAGERECT, or WM_PSD_MINMARGINRECT), the dialog box sends no more messages and does not draw in the sample page until
+ /// the next time the system needs to redraw the sample page. If the hook procedure returns FALSE for all three messages, the
+ /// dialog box sends the remaining messages of the drawing sequence.
+ ///
+ ///
+ /// If the hook procedure returns TRUE for any of the remaining messages in a drawing sequence, the dialog box does not draw
+ /// the corresponding portion of the sample page. If the hook procedure returns FALSE for any of these messages, the dialog
+ /// box draws that portion of the sample page.
+ ///
+ ///
+ ///
+ ///
+ /// The Page Setup dialog box includes an image of a sample page that shows how the user's selections affect the appearance
+ /// of the printed output. The image consists of a rectangle that represents the selected paper or envelope type, with a dotted-line
+ /// rectangle representing the current margins, and partial (Greek text) characters to show how text looks on the printed page. When
+ /// you use the PageSetupDlg function to create a Page Setup dialog box, you can provide a PagePaintHook hook procedure to
+ /// customize the appearance of the sample page.
+ ///
+ ///
+ /// To enable the hook procedure, use the PAGESETUPDLG structure that you passed to the creation function. Specify the pointer to
+ /// the hook procedure in the lpfnPagePaintHook member and specify the PSD_ENABLEPAGEPAINTHOOK flag in the
+ /// Flags member.
+ ///
+ ///
+ /// Whenever the dialog box is about to draw the contents of the sample page, the hook procedure receives the following messages in
+ /// the order in which they are listed.
+ ///
+ ///
+ ///
+ /// Message
+ /// Meaning
+ ///
+ /// -
+ /// WM_PSD_PAGESETUPDLG
+ ///
+ /// The dialog box is about to draw the sample page. The hook procedure can use this message to prepare to draw the contents of the
+ /// sample page.
+ ///
+ ///
+ /// -
+ /// WM_PSD_FULLPAGERECT
+ /// The dialog box is about to draw the sample page. This message specifies the bounding rectangle of the sample page.
+ ///
+ /// -
+ /// WM_PSD_MINMARGINRECT
+ /// The dialog box is about to draw the sample page. This message specifies the margin rectangle.
+ ///
+ /// -
+ /// WM_PSD_MARGINRECT
+ /// The dialog box is about to draw the margin rectangle.
+ ///
+ /// -
+ /// WM_PSD_GREEKTEXTRECT
+ /// The dialog box is about to draw the Greek text inside the margin rectangle.
+ ///
+ /// -
+ /// WM_PSD_ENVSTAMPRECT
+ ///
+ /// The dialog box is about to draw in the envelope-stamp rectangle of an envelope sample page. This message is sent for envelopes only.
+ ///
+ ///
+ /// -
+ /// WM_PSD_YAFULLPAGERECT
+ ///
+ /// The dialog box is about to draw the return address portion of an envelope sample page. This message is sent for envelopes and
+ /// other paper sizes.
+ ///
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nc-commdlg-lppagepainthook LPPAGEPAINTHOOK Lppagepainthook; UINT_PTR
+ // Lppagepainthook( HWND Arg1, UINT Arg2, WPARAM Arg3, LPARAM Arg4 ) {...}
+ [PInvokeData("commdlg.h", MSDNShortId = "NC:commdlg.LPPAGEPAINTHOOK")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate IntPtr LPPAGEPAINTHOOK(HWND Arg1, uint Arg2, IntPtr Arg3, IntPtr Arg4);
+
+ ///
+ ///
+ /// Receives messages or notifications intended for the default dialog box procedure of the Page Setup dialog box. The
+ /// PageSetupHook hook procedure is an application-defined or library-defined callback function used with the PageSetupDlg function.
+ ///
+ ///
+ /// The LPPAGESETUPHOOK type defines a pointer to this callback function. PageSetupHook is a placeholder for the
+ /// application-defined or library-defined function name.
+ ///
+ ///
+ /// A handle to the Page Setup dialog box for which the message is intended.
+ /// The identifier of the message being received.
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ ///
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ ///
+ /// If the Arg2 parameter indicates the WM_INITDIALOG message, Arg4 is a pointer to a PAGESETUPDLG structure containing the values
+ /// specified when the dialog box was created.
+ ///
+ ///
+ ///
+ /// If the hook procedure returns zero, the default dialog box procedure processes the message.
+ /// If the hook procedure returns a nonzero value, the default dialog box procedure ignores the message.
+ ///
+ ///
+ ///
+ /// When you use the PageSetupDlg function to create a Page Setup dialog box, you can provide a PageSetupHook hook procedure
+ /// to process messages or notifications intended for the dialog box procedure. To enable the hook procedure, use the PAGESETUPDLG
+ /// structure that you passed to the dialog creation function. Specify the pointer to the hook procedure in the
+ /// lpfnPageSetupHook member and specify the PSD_ENABLEPAGESETUPHOOK flag in the Flags member.
+ ///
+ ///
+ /// The default dialog box procedure processes the WM_INITDIALOG message before passing it to the hook procedure. For all other
+ /// messages, the hook procedure receives the message first. Then, the return value of the hook procedure determines whether the
+ /// default dialog procedure processes the message or ignores it.
+ ///
+ ///
+ /// If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid brush handle to painting the background of
+ /// the dialog box. In general, if the hook procedure processes any WM_CTLCOLOR* message, it must return a valid brush handle
+ /// to painting the background of the specified control.
+ ///
+ ///
+ /// Do not call the EndDialog function from the hook procedure. Instead, the hook procedure can call the PostMessage function to
+ /// post a WM_COMMAND message with the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog
+ /// box and causes the dialog box function to return FALSE. If you need to know why the hook procedure closed the dialog box,
+ /// you must provide your own communication mechanism between the hook procedure and your application.
+ ///
+ ///
+ /// You can subclass the standard controls of a common dialog box. However, the dialog box procedure may also subclass the controls.
+ /// Because of this, you should subclass controls when your hook procedure processes the WM_INITDIALOG message. This ensures that
+ /// your subclass procedure receives the control-specific messages before the subclass procedure set by the dialog box procedure.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nc-commdlg-lppagesetuphook LPPAGESETUPHOOK Lppagesetuphook; UINT_PTR
+ // Lppagesetuphook( HWND Arg1, UINT Arg2, WPARAM Arg3, LPARAM Arg4 ) {...}
+ [PInvokeData("commdlg.h", MSDNShortId = "NC:commdlg.LPPAGESETUPHOOK")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate IntPtr LPPAGESETUPHOOK(HWND Arg1, uint Arg2, IntPtr Arg3, IntPtr Arg4);
+
+ ///
+ ///
+ /// Receives messages or notifications intended for the default dialog box procedure of the Print dialog box. This is an
+ /// application-defined or library-defined callback function that is used with the PrintDlg function.
+ ///
+ ///
+ /// The LPPRINTHOOKPROC type defines a pointer to this callback function. PrintHookProc is a placeholder for the
+ /// application-defined or library-defined function name.
+ ///
+ ///
+ /// A handle to the Print dialog box for which the message is intended.
+ /// The identifier of the message being received.
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ ///
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ ///
+ /// If the Arg2 parameter indicates the WM_INITDIALOG message, Arg4 is a pointer to a PRINTDLG structure containing the values
+ /// specified when the dialog box was created.
+ ///
+ ///
+ ///
+ /// If the hook procedure returns zero, the default dialog box procedure processes the message.
+ /// If the hook procedure returns a nonzero value, the default dialog box procedure ignores the message.
+ ///
+ ///
+ ///
+ /// When you use the PrintDlg function to create a Print dialog box, you can provide a PrintHookProc hook procedure to
+ /// process messages or notifications intended for the dialog box procedure. To enable the hook procedure, use the PRINTDLG
+ /// structure that you passed to the dialog creation function. Specify the address of the hook procedure in the lpfnPrintHook
+ /// member and specify the PD_ENABLEPRINTHOOK flag in the Flags member.
+ ///
+ ///
+ /// The default dialog box procedure processes the WM_INITDIALOG message before passing it to the hook procedure. For all other
+ /// messages, the hook procedure receives the message first. Then, the return value of the hook procedure determines whether the
+ /// default dialog procedure processes the message or ignores it.
+ ///
+ ///
+ /// If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid brush handle to painting the background of
+ /// the dialog box. In general, if the hook procedure processes any WM_CTLCOLOR* message, it must return a valid brush handle
+ /// to painting the background of the specified control.
+ ///
+ ///
+ /// Do not call the EndDialog function from the hook procedure. Instead, the hook procedure can call the PostMessage function to
+ /// post a WM_COMMAND message with the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog
+ /// box and causes the dialog box function to return FALSE. If you need to know why the hook procedure closed the dialog box,
+ /// you must provide your own communication mechanism between the hook procedure and your application.
+ ///
+ ///
+ /// You can subclass the standard controls of a common dialog box. However, the dialog box procedure may also subclass the controls.
+ /// Because of this, you should subclass controls when your hook procedure processes the WM_INITDIALOG message. This ensures that
+ /// your subclass procedure receives the control-specific messages before the subclass procedure set by the dialog box procedure.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nc-commdlg-lpprinthookproc LPPRINTHOOKPROC Lpprinthookproc; UINT_PTR
+ // Lpprinthookproc( HWND Arg1, UINT Arg2, WPARAM Arg3, LPARAM Arg4 ) {...}
+ [PInvokeData("commdlg.h", MSDNShortId = "NC:commdlg.LPPRINTHOOKPROC")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate IntPtr LPPRINTHOOKPROC(HWND Arg1, uint Arg2, IntPtr Arg3, IntPtr Arg4);
+
+ ///
+ ///
+ /// An application-defined or library-defined callback function used with the PrintDlg function. The hook procedure receives
+ /// messages or notifications intended for the default dialog box procedure of the Print Setup dialog box.
+ ///
+ ///
+ /// The LPSETUPHOOKPROC type defines a pointer to this callback function. SetupHookProc is a placeholder for the
+ /// application-defined or library-defined function name.
+ ///
+ ///
+ /// A handle to the Print Setup dialog box for which the message is intended.
+ /// The identifier of the message being received.
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
+ ///
+ /// If the hook procedure returns zero, the default dialog box procedure processes the message.
+ /// If the hook procedure returns a nonzero value, the default dialog box procedure ignores the message.
+ ///
+ ///
+ ///
+ /// The Print Setup dialog box has been superseded by the Page Setup dialog box, which should be used by new
+ /// applications. However, for compatibility, the PrintDlg function continues to support display of the Print Setup dialog
+ /// box. You can provide a SetupHookProc hook procedure for the Print Setup dialog box to process messages or notifications
+ /// intended for the dialog box procedure.
+ ///
+ ///
+ /// To enable the hook procedure, use the PRINTDLG structure that you passed to the dialog creation function. Specify the address of
+ /// the hook procedure in the lpfnSetupHook member and specify the PD_ENABLESETUPHOOK flag in the Flags member.
+ ///
+ ///
+ /// The default dialog box procedure processes the WM_INITDIALOG message before passing it to the hook procedure. For all other
+ /// messages, the hook procedure receives the message first. Then, the return value of the hook procedure determines whether the
+ /// default dialog procedure processes the message or ignores it.
+ ///
+ ///
+ /// If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid brush handle to painting the background of
+ /// the dialog box. In general, if the hook procedure processes any WM_CTLCOLOR* message, it must return a valid brush handle
+ /// to painting the background of the specified control.
+ ///
+ ///
+ /// Do not call the EndDialog function from the hook procedure. Instead, the hook procedure can call the PostMessage function to
+ /// post a WM_COMMAND message with the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog
+ /// box and causes the dialog box function to return FALSE. If you need to know why the hook procedure closed the dialog box,
+ /// you must provide your own communication mechanism between the hook procedure and your application.
+ ///
+ ///
+ /// You can subclass the standard controls of a common dialog box. However, the dialog box procedure may also subclass the controls.
+ /// Because of this, you should subclass controls when your hook procedure processes the WM_INITDIALOG message. This ensures that
+ /// your subclass procedure receives the control-specific messages before the subclass procedure set by the dialog box procedure.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nc-commdlg-lpsetuphookproc LPSETUPHOOKPROC Lpsetuphookproc; UINT_PTR
+ // Lpsetuphookproc( HWND Arg1, UINT Arg2, WPARAM Arg3, LPARAM Arg4 ) {...}
+ [PInvokeData("commdlg.h", MSDNShortId = "NC:commdlg.LPSETUPHOOKPROC")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate IntPtr LPSETUPHOOKPROC(HWND Arg1, uint Arg2, IntPtr Arg3, IntPtr Arg4);
+
+ ///
+ /// Provides methods that enable an application to receive notifications and messages from the PrintDlgEx function while the Print
+ /// Property Sheet is displayed.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nn-commdlg-iprintdialogcallback
+ [PInvokeData("commdlg.h", MSDNShortId = "NN:commdlg.IPrintDialogCallback")]
+ [ComImport, Guid("5852A2C3-6530-11D1-B6A3-0000F8757BF9"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IPrintDialogCallback
+ {
+ ///
+ /// Called by PrintDlgEx when the system has finished initializing the General page of the Print Property Sheet.
+ ///
+ ///
+ /// Type: HRESULT
+ /// Return S_OK to prevent the PrintDlgEx function from performing its default actions.
+ ///
+ /// Return S_FALSE to allow PrintDlgEx to perform its default actions. Currently, PrintDlgEx does not perform any
+ /// default processing after the InitDone call.
+ ///
+ ///
+ ///
+ /// If your callback object implements the IObjectWithSite interface, the PrintDlgEx function calls the IObjectWithSite::SetSite
+ /// method to pass an IPrintDialogServices pointer to the callback object. The PrintDlgEx function calls the
+ /// IObjectWithSite::SetSite method before calling the InitDone method. This enables your InitDone
+ /// implementation to use the IPrintDialogServices methods to retrieve information about the currently selected printer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-iprintdialogcallback-initdone HRESULT InitDone();
+ [PreserveSig]
+ HRESULT InitDone();
+
+ ///
+ /// Called by PrintDlgEx when the user selects a different printer from the list of installed printers on the General
+ /// page of the Print Property Sheet.
+ ///
+ ///
+ /// Type: HRESULT
+ /// Return S_OK to prevent the PrintDlgEx function from performing its default actions.
+ ///
+ /// Return S_FALSE to allow PrintDlgEx to perform its default actions, which include adjustments to the Copies,
+ /// Collate, and Print Range items.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-iprintdialogcallback-selectionchange HRESULT SelectionChange();
+ [PreserveSig]
+ HRESULT SelectionChange();
+
+ ///
+ /// Called by PrintDlgEx to give your application an opportunity to handle messages sent to the child dialog box in the lower
+ /// portion of the General page of the Print Property Sheet. The child dialog box contains controls similar to those of
+ /// the Print dialog box.
+ ///
+ ///
+ /// Type: HWND
+ /// A handle to the child dialog box in the lower portion of the General page.
+ ///
+ ///
+ /// Type: UINT
+ /// The identifier of the message being received.
+ ///
+ ///
+ /// Type: WPARAM
+ /// Additional information about the message. The exact meaning depends on the value of the uMsg parameter.
+ ///
+ ///
+ /// Type: LPARAM
+ /// Additional information about the message. The exact meaning depends on the value of the uMsg parameter.
+ ///
+ /// If the uMsg parameter indicates the WM_INITDIALOG message, lParam is a pointer to a PRINTDLGEX structure containing the
+ /// values specified when the property sheet was created.
+ ///
+ ///
+ ///
+ /// Type: LRESULT*
+ ///
+ /// Indicates the result to be returned by the dialog box procedure for the message. The value pointed to should be TRUE
+ /// if you process the message, otherwise it should be FALSE or whatever is an appropriate value according to the message type.
+ ///
+ ///
+ ///
+ /// Type: HRESULT
+ ///
+ /// Return S_OK if your IPrintDialogCallback::HandleMessage implementation handled the message. In this case, the
+ /// PrintDlgEx function does not perform any default message handling.
+ ///
+ /// Return S_FALSE if you want PrintDlgEx to perform its default message handling.
+ ///
+ ///
+ ///
+ /// For notification messages passed by the WM_NOTIFY message, you must use the SetWindowLong function with the
+ /// DWL_MSGRESULT value to set a return value. When you call SetWindowLong, use GetParent(hDlg) to set the
+ /// DWL_MSGRESULT value of the General page, which is the parent of the child window.
+ ///
+ ///
+ /// The default dialog box procedure for the child window in the lower portion of the General page processes the
+ /// WM_INITDIALOG message before passing it to the HandleMessage method. For all other messages sent to the child window,
+ /// HandleMessage receives the message first. Then the HandleMessage return value determines whether the default
+ /// dialog procedure processes the message or ignores it.
+ ///
+ ///
+ /// If HandleMessage processes the WM_CTLCOLORDLG message, it must return a valid brush handle to painting the background
+ /// of the dialog box. In general, if HandleMessage processes any WM_CTLCOLOR* message, it must return a valid
+ /// brush handle to painting the background of the specified control.
+ ///
+ ///
+ /// Do not call the EndDialog function from the HandleMessage method. Instead, HandleMessage can call the
+ /// PostMessage function to post a WM_COMMAND message with the IDABORT value to the dialog box procedure. Posting IDABORT
+ /// closes the Print Property Sheet and causes PrintDlgEx to return PD_RESULT_CANCEL in the dwResultAction member
+ /// of the PRINTDLGEX structure. If you need to know why HandleMessage closed the dialog box, you must provide your own
+ /// communication mechanism between the HandleMessage method and your application.
+ ///
+ ///
+ /// You can subclass the standard controls of the child dialog box in the lower portion of the General page. These
+ /// standard controls are similar to those found in the Print dialog box. However, the default dialog box procedure may
+ /// also subclass the controls. Because of this, you should subclass controls when HandleMessage processes the
+ /// WM_INITDIALOG message. This ensures that your subclass procedure receives control-specific messages before the subclass
+ /// procedure set by the dialog box procedure.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-iprintdialogcallback-handlemessage HRESULT
+ // HandleMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pResult );
+ [PreserveSig]
+ HRESULT HandleMessage(HWND hDlg, uint uMsg, IntPtr wParam, IntPtr lParam, out IntPtr pResult);
+ }
+
+ ///
+ /// Provides methods that enable an application using the PrintDlgEx function to retrieve information about the currently selected printer.
+ ///
+ /// This printer is indicated on the list of installed printers on the General page of the Print Property Sheet.
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nn-commdlg-iprintdialogservices
+ [PInvokeData("commdlg.h", MSDNShortId = "NN:commdlg.IPrintDialogServices")]
+ [ComImport, Guid("509AAEDA-5639-11D1-B6A1-0000F8757BF9"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IPrintDialogServices
+ {
+ /// Fills a DEVMODE structure with information about the currently selected printer for use with PrintDlgEx.
+ ///
+ /// Type: LPDEVMODE
+ /// A pointer to a buffer that receives a DEVMODE structure containing information about the currently selected printer.
+ ///
+ ///
+ /// Type: UINT*
+ ///
+ /// On input, the variable specifies the size, in bytes, of the buffer pointed to by the lpDevMode parameter. On output, the
+ /// variable contains the number of bytes written to lpDevMode.
+ ///
+ ///
+ /// If the size is zero on input, the function returns the required buffer size (in bytes) in pcbSize and does not use the
+ /// lpDevMode buffer.
+ ///
+ ///
+ ///
+ /// Type: HRESULT
+ ///
+ /// If the method is successful, the return value is S_OK. If no printer is currently selected, the return value is
+ /// S_OK, the value returned in pcbSize is zero, and the lpDevMode buffer is unchanged.
+ ///
+ /// If an error occurs, the return value is a COM error code. For more information, see Error Handling.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-iprintdialogservices-getcurrentdevmode HRESULT
+ // GetCurrentDevMode( LPDEVMODE pDevMode, UINT *pcbSize );
+ [PreserveSig]
+ HRESULT GetCurrentDevMode(ref DEVMODE pDevMode, ref uint pcbSize);
+
+ /// Retrieves the name of the currently selected printer, for use with PrintDlgEx.
+ ///
+ /// Type: LPTSTR
+ /// The name of the currently selected printer.
+ ///
+ ///
+ /// Type: UINT*
+ ///
+ /// On input, the variable specifies the size, in characters, of the buffer pointed to by the lpPrinterName parameter. On
+ /// output, the variable contains the number of bytes (ANSI) or characters (Unicode), including the terminating null character,
+ /// written to the buffer.
+ ///
+ ///
+ /// If the size is zero on input, the function returns the required buffer size (in bytes or characters) in pcchSize and does
+ /// not use the lpPrinterName buffer.
+ ///
+ ///
+ ///
+ /// Type: HRESULT
+ ///
+ /// If the method is successful, the return value is S_OK. If no printer is currently selected, the return value is
+ /// S_OK, the value returned in pcchSize is zero, and the lpPrinterName buffer is unchanged.
+ ///
+ /// If an error occurs, the return value is a COM error code. For more information, see Error Handling.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-iprintdialogservices-getcurrentprintername HRESULT
+ // GetCurrentPrinterName( LPWSTR pPrinterName, UINT *pcchSize );
+ [PreserveSig]
+ HRESULT GetCurrentPrinterName([MarshalAs(UnmanagedType.LPWStr)] StringBuilder pPrinterName, ref uint pcchSize);
+
+ /// Retrieves the name of the current port for use with PrintDlgEx.
+ ///
+ /// Type: LPTSTR
+ /// The name of the current port.
+ ///
+ ///
+ /// Type: UINT*
+ ///
+ /// On input, the variable specifies the size, in characters, of the buffer pointed to by the lpPortName parameter. On output,
+ /// the variable contains the number of bytes (ANSI) or characters (Unicode), including the terminating null character, written
+ /// to the buffer.
+ ///
+ ///
+ /// If the size is zero on input, the function returns the required buffer size (in bytes or characters) in pcchSize and does
+ /// not use the lpPortName buffer.
+ ///
+ ///
+ ///
+ /// Type: HRESULT
+ ///
+ /// If the method is successful, the return value is S_OK. If there is no current port, the return value is S_OK,
+ /// the value returned in pcchSize is zero, and the lpPortName buffer is unchanged.
+ ///
+ /// If an error occurs, the return value is a COM error code. For more information, see Error Handling.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-iprintdialogservices-getcurrentportname HRESULT
+ // GetCurrentPortName( LPWSTR pPortName, UINT *pcchSize );
+ [PreserveSig]
+ HRESULT GetCurrentPortName([MarshalAs(UnmanagedType.LPWStr)] StringBuilder pPortName, ref uint pcchSize);
+ }
+
+ /// Creates a Color dialog box that enables the user to select a color.
+ ///
+ /// [in, out] Type: LPCHOOSECOLOR
+ ///
+ /// A pointer to a CHOOSECOLOR structure that contains information used to initialize the dialog box. When ChooseColor
+ /// returns, this structure contains information about the user's color selection.
+ ///
+ ///
+ ///
+ /// Type: BOOL
+ ///
+ /// If the user clicks the OK button of the dialog box, the return value is nonzero. The rgbResult member of the
+ /// CHOOSECOLOR structure contains the RGB color value of the color selected by the user.
+ ///
+ ///
+ /// If the user cancels or closes the Color dialog box or an error occurs, the return value is zero. To get extended error
+ /// information, call the CommDlgExtendedError function, which can return one of the following values:
+ ///
+ /// CDERR_DIALOGFAILURE
+ /// CDERR_FINDRESFAILURE
+ /// CDERR_MEMLOCKFAILURE
+ /// CDERR_INITIALIZATION
+ /// CDERR_NOHINSTANCE
+ /// CDERR_NOHOOK
+ /// CDERR_LOADRESFAILURE
+ /// CDERR_NOTEMPLATE
+ /// CDERR_LOADSTRFAILURE
+ /// CDERR_STRUCTSIZE
+ /// CDERR_MEMALLOCFAILURE
+ ///
+ ///
+ ///
+ /// The Color dialog box does not support palettes. The color choices offered by the dialog box are limited to the system
+ /// colors and dithered versions of those colors.
+ ///
+ ///
+ /// You can provide a CCHookProc hook procedure for a Color dialog box. The hook procedure can process messages sent
+ /// to the dialog box. To enable a hook procedure, set the CC_ENABLEHOOK flag in the Flags member of the
+ /// CHOOSECOLOR structure and specify the address of the hook procedure in the lpfnHook member.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms646912(v=vs.85)
+ // BOOL WINAPI ChooseColor( _Inout_ LPCHOOSECOLOR lpcc );
+ [DllImport(Lib_ComDlg32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("Commdlg.h")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool ChooseColor(ref CHOOSECOLOR lpcc);
+
+ ///
+ /// Creates a Font dialog box that enables the user to choose attributes for a logical font. These attributes include a font
+ /// family and associated font style, a point size, effects (underline, strikeout, and text color), and a script (or character set).
+ ///
+ ///
+ /// [in, out] Type: LPCHOOSEFONT
+ ///
+ /// A pointer to a CHOOSEFONT structure that contains information used to initialize the dialog box. When ChooseFont
+ /// returns, this structure contains information about the user's font selection.
+ ///
+ ///
+ ///
+ /// Type: BOOL
+ ///
+ /// If the user clicks the OK button of the dialog box, the return value is TRUE. The members of the CHOOSEFONT
+ /// structure indicate the user's selections.
+ ///
+ ///
+ /// If the user cancels or closes the Font dialog box or an error occurs, the return value is FALSE. To get extended
+ /// error information, call the CommDlgExtendedError function, which can return one of the following values.
+ ///
+ /// CDERR_DIALOGFAILURE
+ /// CDERR_FINDRESFAILURE
+ /// CDERR_NOHINSTANCE
+ /// CDERR_INITIALIZATION
+ /// CDERR_NOHOOK
+ /// CDERR_LOCKRESFAILURE
+ /// CDERR_NOTEMPLATE
+ /// CDERR_LOADRESFAILURE
+ /// CDERR_STRUCTSIZE
+ /// CDERR_LOADSTRFAILURE
+ /// CFERR_MAXLESSTHANMIN
+ /// CDERR_MEMALLOCFAILURE
+ /// CFERR_NOFONTS
+ /// CDERR_MEMLOCKFAILURE
+ ///
+ ///
+ ///
+ /// You can provide a CFHookProc hook procedure for a Font dialog box. The hook procedure can process messages sent to
+ /// the dialog box. To enable a hook procedure, set the CF_ENABLEHOOK flag in the Flags member of the
+ /// CHOOSEFONT structure and specify the address of the hook procedure in the lpfnHook member.
+ ///
+ ///
+ /// The hook procedure can send the WM_CHOOSEFONT_GETLOGFONT, WM_CHOOSEFONT_SETFLAGS, and
+ /// WM_CHOOSEFONT_SETLOGFONT messages to the dialog box to get and set the current values and flags of the dialog box.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms646914(v=vs.85)
+ // BOOL WINAPI ChooseFont( _Inout_ LPCHOOSEFONT lpcf );
+ [DllImport(Lib.comdlg32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("Commdlg.h")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool ChooseFont(ref CHOOSEFONT lpcf);
+
+ ///
+ /// Returns a common dialog box error code. This code indicates the most recent error to occur during the execution of one of the
+ /// common dialog box functions.
+ ///
+ ///
+ /// Type: DWORD
+ ///
+ /// If the most recent call to a common dialog box function succeeded, the return value is undefined. If the common dialog box
+ /// function returned FALSE because the user closed or canceled the dialog box, the return value is zero. Otherwise, the
+ /// return value is a nonzero error code.
+ ///
+ ///
+ /// The CommDlgExtendedError function can return general error codes for any of the common dialog box functions. In addition,
+ /// there are error codes that are returned only for a specific common dialog box. All of these error codes are defined in Cderr.h.
+ /// The following general error codes can be returned for any of the common dialog box functions.
+ ///
+ ///
+ ///
+ /// Return code/value
+ /// Description
+ ///
+ /// -
+ /// CDERR_DIALOGFAILURE 0xFFFF
+ ///
+ /// The dialog box could not be created. The common dialog box function's call to the DialogBox function failed. For example, this
+ /// error occurs if the common dialog box call specifies an invalid window handle.
+ ///
+ ///
+ /// -
+ /// CDERR_FINDRESFAILURE 0x0006
+ /// The common dialog box function failed to find a specified resource.
+ ///
+ /// -
+ /// CDERR_INITIALIZATION 0x0002
+ /// The common dialog box function failed during initialization. This error often occurs when sufficient memory is not available.
+ ///
+ /// -
+ /// CDERR_LOADRESFAILURE 0x0007
+ /// The common dialog box function failed to load a specified resource.
+ ///
+ /// -
+ /// CDERR_LOADSTRFAILURE 0x0005
+ /// The common dialog box function failed to load a specified string.
+ ///
+ /// -
+ /// CDERR_LOCKRESFAILURE 0x0008
+ /// The common dialog box function failed to lock a specified resource.
+ ///
+ /// -
+ /// CDERR_MEMALLOCFAILURE 0x0009
+ /// The common dialog box function was unable to allocate memory for internal structures.
+ ///
+ /// -
+ /// CDERR_MEMLOCKFAILURE 0x000A
+ /// The common dialog box function was unable to lock the memory associated with a handle.
+ ///
+ /// -
+ /// CDERR_NOHINSTANCE 0x0004
+ ///
+ /// The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box, but
+ /// you failed to provide a corresponding instance handle.
+ ///
+ ///
+ /// -
+ /// CDERR_NOHOOK 0x000B
+ ///
+ /// The ENABLEHOOK flag was set in the Flags member of the initialization structure for the corresponding common dialog box, but you
+ /// failed to provide a pointer to a corresponding hook procedure.
+ ///
+ ///
+ /// -
+ /// CDERR_NOTEMPLATE 0x0003
+ ///
+ /// The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box, but
+ /// you failed to provide a corresponding template.
+ ///
+ ///
+ /// -
+ /// CDERR_REGISTERMSGFAIL 0x000C
+ /// The RegisterWindowMessage function returned an error code when it was called by the common dialog box function.
+ ///
+ /// -
+ /// CDERR_STRUCTSIZE 0x0001
+ /// The lStructSize member of the initialization structure for the corresponding common dialog box is invalid.
+ ///
+ ///
+ /// The following error codes can be returned for the PrintDlg function.
+ ///
+ ///
+ /// Return code/value
+ /// Description
+ ///
+ /// -
+ /// PDERR_CREATEICFAILURE 0x100A
+ /// The PrintDlg function failed when it attempted to create an information context.
+ ///
+ /// -
+ /// PDERR_DEFAULTDIFFERENT 0x100C
+ ///
+ /// You called the PrintDlg function with the DN_DEFAULTPRN flag specified in the wDefault member of the DEVNAMES structure, but the
+ /// printer described by the other structure members did not match the current default printer. This error occurs when you store the
+ /// DEVNAMES structure, and the user changes the default printer by using the Control Panel. To use the printer described by the
+ /// DEVNAMES structure, clear the DN_DEFAULTPRN flag and call PrintDlg again. To use the default printer, replace the DEVNAMES
+ /// structure (and the structure, if one exists) with NULL; and call PrintDlg again.
+ ///
+ ///
+ /// -
+ /// PDERR_DNDMMISMATCH 0x1009
+ /// The data in the DEVMODE and DEVNAMES structures describes two different printers.
+ ///
+ /// -
+ /// PDERR_GETDEVMODEFAIL 0x1005
+ /// The printer driver failed to initialize a DEVMODE structure.
+ ///
+ /// -
+ /// PDERR_INITFAILURE 0x1006
+ ///
+ /// The PrintDlg function failed during initialization, and there is no more specific extended error code to describe the failure.
+ /// This is the generic default error code for the function.
+ ///
+ ///
+ /// -
+ /// PDERR_LOADDRVFAILURE 0x1004
+ /// The PrintDlg function failed to load the device driver for the specified printer.
+ ///
+ /// -
+ /// PDERR_NODEFAULTPRN 0x1008
+ /// A default printer does not exist.
+ ///
+ /// -
+ /// PDERR_NODEVICES 0x1007
+ /// No printer drivers were found.
+ ///
+ /// -
+ /// PDERR_PARSEFAILURE 0x1002
+ /// The PrintDlg function failed to parse the strings in the [devices] section of the WIN.INI file.
+ ///
+ /// -
+ /// PDERR_PRINTERNOTFOUND 0x100B
+ /// The [devices] section of the WIN.INI file did not contain an entry for the requested printer.
+ ///
+ /// -
+ /// PDERR_RETDEFFAILURE 0x1003
+ ///
+ /// The PD_RETURNDEFAULT flag was specified in the Flags member of the PRINTDLG structure, but the hDevMode or hDevNames member was
+ /// not NULL.
+ ///
+ ///
+ /// -
+ /// PDERR_SETUPFAILURE 0x1001
+ /// The PrintDlg function failed to load the required resources.
+ ///
+ ///
+ /// The following error codes can be returned for the ChooseFont function.
+ ///
+ ///
+ /// Return code/value
+ /// Description
+ ///
+ /// -
+ /// CFERR_MAXLESSTHANMIN CFERR_MAXLESSTHANMIN
+ ///
+ /// The size specified in the nSizeMax member of the CHOOSEFONT structure is less than the size specified in the nSizeMin member.
+ ///
+ ///
+ /// -
+ /// CFERR_NOFONTS 0x2001
+ /// No fonts exist.
+ ///
+ ///
+ /// The following error codes can be returned for the GetOpenFileName and GetSaveFileName functions.
+ ///
+ ///
+ /// Return code/value
+ /// Description
+ ///
+ /// -
+ /// FNERR_BUFFERTOOSMALL 0x3003
+ ///
+ /// The buffer pointed to by the lpstrFile member of the OPENFILENAME structure is too small for the file name specified by the
+ /// user. The first two bytes of the lpstrFile buffer contain an integer value specifying the size required to receive the full
+ /// name, in characters.
+ ///
+ ///
+ /// -
+ /// FNERR_INVALIDFILENAME 0x3002
+ /// A file name is invalid.
+ ///
+ /// -
+ /// FNERR_SUBCLASSFAILURE 0x3001
+ /// An attempt to subclass a list box failed because sufficient memory was not available.
+ ///
+ ///
+ /// The following error code can be returned for the FindText and ReplaceText functions.
+ ///
+ ///
+ /// Return code/value
+ /// Description
+ ///
+ /// -
+ /// FRERR_BUFFERLENGTHZERO 0x4001
+ /// A member of the FINDREPLACE structure points to an invalid buffer.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-commdlgextendederror DWORD CommDlgExtendedError();
+ [DllImport(Lib_ComDlg32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("commdlg.h", MSDNShortId = "NF:commdlg.CommDlgExtendedError")]
+ public static extern uint CommDlgExtendedError();
+
+ ///
+ /// Creates a system-defined modeless Find dialog box that lets the user specify a string to search for and options to use
+ /// when searching for text in a document.
+ ///
+ ///
+ /// Type: LPFINDREPLACE
+ ///
+ /// A pointer to a FINDREPLACE structure that contains information used to initialize the dialog box. The dialog box uses this
+ /// structure to send information about the user's input to your application. For more information, see the following Remarks section.
+ ///
+ ///
+ ///
+ /// Type: HWND
+ ///
+ /// If the function succeeds, the return value is the window handle to the dialog box. You can use the window handle to communicate
+ /// with or to close the dialog box.
+ ///
+ ///
+ /// If the function fails, the return value is NULL. To get extended error information, call the CommDlgExtendedError
+ /// function. CommDlgExtendedError may return one of the following error codes:
+ ///
+ ///
+ ///
+ ///
+ /// The FindText function does not perform a search operation. Instead, the dialog box sends FINDMSGSTRING registered
+ /// messages to the window procedure of the owner window of the dialog box. When you create the dialog box, the hwndOwner
+ /// member of the FINDREPLACE structure is a handle to the owner window.
+ ///
+ ///
+ /// Before calling FindText, you must call the RegisterWindowMessage function to get the identifier for the FINDMSGSTRING
+ /// message. The dialog box procedure uses this identifier to send messages when the user clicks the Find Next button, or
+ /// when the dialog box is closing. The lParam parameter of the FINDMSGSTRING message contains a pointer to a FINDREPLACE
+ /// structure. The Flags member of this structure indicates the event that caused the message. Other members of the structure
+ /// indicate the user's input.
+ ///
+ ///
+ /// If you create a Find dialog box, you must also use the IsDialogMessage function in the main message loop of your
+ /// application to ensure that the dialog box correctly processes keyboard input, such as the TAB and ESC keys.
+ /// IsDialogMessage returns a value that indicates whether the Find dialog box processed the message.
+ ///
+ ///
+ /// You can provide an FRHookProc hook procedure for a Find dialog box. The hook procedure can process messages sent to the
+ /// dialog box. To enable a hook procedure, set the FR_ENABLEHOOK flag in the Flags member of the FINDREPLACE
+ /// structure and specify the address of the hook procedure in the lpfnHook member.
+ ///
+ /// Examples
+ /// For an example, see Finding Text.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-findtexta HWND FindTextA( LPFINDREPLACEA Arg1 );
+ [DllImport(Lib_ComDlg32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("commdlg.h", MSDNShortId = "NF:commdlg.FindTextA")]
+ public static extern HWND FindText(ref FINDREPLACE Arg1);
+
+ /// Retrieves the name of the specified file.
+ ///
+ /// Type: LPCTSTR
+ /// The name and location of a file.
+ ///
+ ///
+ /// Type: LPTSTR
+ /// The buffer that receives the name of the file.
+ ///
+ ///
+ /// Type: WORD
+ /// The length, in characters, of the buffer pointed to by the lpszTitle parameter.
+ ///
+ ///
+ /// Type: short
+ /// If the function succeeds, the return value is zero.
+ /// If the file name is invalid, the return value is unknown. If there is an error, the return value is a negative number.
+ ///
+ /// If the buffer pointed to by the lpszTitle parameter is too small, the return value is a positive integer that specifies the
+ /// required buffer size, in characters. The required buffer size includes the terminating null character.
+ ///
+ ///
+ ///
+ /// GetFileTitle should only be called with legal file names; using an illegal file name has an undefined result.
+ ///
+ /// To get the buffer size needed for the name of a file, call the function with lpszTitle set to NULL and cchSize set to
+ /// zero. The function returns the required size.
+ ///
+ ///
+ /// GetFileTitle returns the string that the system would use to display the file name to the user. The display name includes
+ /// an extension only if that is the user's preference for displaying file names. This means that the returned string may not
+ /// accurately identify the file if it is used in calls to file system functions.
+ ///
+ ///
+ /// If the lpszTitle buffer is too small, GetFileTitle returns the size required to hold the display name. However, there is
+ /// no guaranteed relationship between the required size and the characters originally specified in the lpszFile buffer. For
+ /// example, do not call GetFileTitle with lpszTitle set to NULL and cchSize set to zero, and then try to use the
+ /// return value as an index into the lpszFile string. You can usually achieve similar results (and superior performance) with C
+ /// run-time library functions such as strrchr, wcsrchr, and _mbsrchr.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-getfiletitlea short GetFileTitleA( LPCSTR , LPSTR Buf, WORD
+ // cchSize );
+ [DllImport(Lib_ComDlg32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("commdlg.h", MSDNShortId = "NF:commdlg.GetFileTitleA")]
+ public static extern short GetFileTitle([MarshalAs(UnmanagedType.LPTStr)] string arg1, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder Buf, ushort cchSize);
+
+ ///
+ ///
+ /// [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.]
+ ///
+ ///
+ /// Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or set of files to be opened.
+ ///
+ ///
+ ///
+ /// Type: LPOPENFILENAME
+ ///
+ /// A pointer to an OPENFILENAME structure that contains information used to initialize the dialog box. When GetOpenFileName
+ /// returns, this structure contains information about the user's file selection.
+ ///
+ ///
+ ///
+ /// Type: BOOL
+ ///
+ /// If the user specifies a file name and clicks the OK button, the return value is nonzero. The buffer pointed to by the
+ /// lpstrFile member of the OPENFILENAME structure contains the full path and file name specified by the user.
+ ///
+ ///
+ /// If the user cancels or closes the Open dialog box or an error occurs, the return value is zero. To get extended error
+ /// information, call the CommDlgExtendedError function, which can return one of the following values.
+ ///
+ ///
+ ///
+ ///
+ /// The Explorer-style Open dialog box provides user-interface features that are similar to the Windows Explorer. You can
+ /// provide an OFNHookProc hook procedure for an Explorer-style Open dialog box. To enable the hook procedure, set the
+ /// OFN_EXPLORER and OFN_ENABLEHOOK flags in the Flags member of the OPENFILENAME structure and specify the
+ /// address of the hook procedure in the lpfnHook member.
+ ///
+ ///
+ /// Windows continues to support the old-style Open dialog box for applications that want to maintain a user-interface
+ /// consistent with the old-style user-interface. To display the old-style Open dialog box, enable an OFNHookProcOldStyle
+ /// hook procedure and ensure that the OFN_EXPLORER flag is not set.
+ ///
+ /// To display a dialog box that allows the user to select a directory instead of a file, call the SHBrowseForFolder function.
+ /// Note, when selecting multiple files, the total character limit for the file names depends on the version of the function.
+ ///
+ /// -
+ /// ANSI: 32k limit
+ ///
+ /// -
+ /// Unicode: no restriction
+ ///
+ ///
+ /// Examples
+ /// For an example, see Opening a File.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-getopenfilenamea BOOL GetOpenFileNameA( LPOPENFILENAMEA
+ // Arg1 );
+ [DllImport(Lib_ComDlg32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("commdlg.h", MSDNShortId = "NF:commdlg.GetOpenFileNameA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool GetOpenFileName(ref OPENFILENAME Arg1);
+
+ ///
+ ///
+ /// [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.]
+ ///
+ /// Creates a Save dialog box that lets the user specify the drive, directory, and name of a file to save.
+ ///
+ ///
+ /// Type: LPOPENFILENAME
+ ///
+ /// A pointer to an OPENFILENAME structure that contains information used to initialize the dialog box. When GetSaveFileName
+ /// returns, this structure contains information about the user's file selection.
+ ///
+ ///
+ ///
+ /// Type: BOOL
+ ///
+ /// If the user specifies a file name and clicks the OK button and the function is successful, the return value is nonzero.
+ /// The buffer pointed to by the lpstrFile member of the OPENFILENAME structure contains the full path and file name
+ /// specified by the user.
+ ///
+ ///
+ /// If the user cancels or closes the Save dialog box or an error such as the file name buffer being too small occurs, the
+ /// return value is zero. To get extended error information, call the CommDlgExtendedError function, which can return one of the
+ /// following values:
+ ///
+ ///
+ ///
+ ///
+ /// The Explorer-style Save dialog box that provides user-interface features that are similar to the Windows Explorer. You
+ /// can provide an OFNHookProc hook procedure for an Explorer-style Save dialog box. To enable the hook procedure, set the
+ /// OFN_EXPLORER and OFN_ENABLEHOOK flags in the Flags member of the OPENFILENAME structure and specify the
+ /// address of the hook procedure in the lpfnHook member.
+ ///
+ ///
+ /// Windows continues to support old-style Save dialog boxes for applications that want to maintain a user-interface
+ /// consistent with the old-style user-interface. To display the old-style Save dialog box, enable an OFNHookProcOldStyle
+ /// hook procedure and ensure that the OFN_EXPLORER flag is not set.
+ ///
+ /// Examples
+ /// For an example, see Creating an Enhanced Metafile.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-getsavefilenamea BOOL GetSaveFileNameA( LPOPENFILENAMEA
+ // Arg1 );
+ [DllImport(Lib_ComDlg32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("commdlg.h", MSDNShortId = "NF:commdlg.GetSaveFileNameA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool GetSaveFileName(ref OPENFILENAME Arg1);
+
+ ///
+ /// Creates a Page Setup dialog box that enables the user to specify the attributes of a printed page. These attributes
+ /// include the paper size and source, the page orientation (portrait or landscape), and the width of the page margins.
+ ///
+ ///
+ /// [in, out] Type: LPPAGESETUPDLG
+ ///
+ /// A pointer to a PAGESETUPDLG structure that contains information used to initialize the dialog box. The structure receives
+ /// information about the user's selections when the function returns.
+ ///
+ ///
+ ///
+ /// Type: BOOL
+ ///
+ /// If the user clicks the OK button, the return value is nonzero. The members of the PAGESETUPDLG structure pointed
+ /// to by the lppsd parameter indicate the user's selections.
+ ///
+ ///
+ /// If the user cancels or closes the Page Setup dialog box or an error occurs, the return value is zero. To get extended
+ /// error information, use the CommDlgExtendedError function
+ ///
+ ///
+ /// Note that the values of hDevMode and hDevNames in PAGESETUPDLG may change when they are passed into
+ /// PageSetupDlg. This is because these members are filled on both input and output.
+ ///
+ ///
+ ///
+ /// Starting with Windows Vista, the PageSetupDlg does not contain the Printer button. To switch printer selection,
+ /// use PrintDlg or PrintDlgEx.
+ ///
+ // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms646937(v=vs.85) BOOL WINAPI PageSetupDlg( _Inout_
+ // LPPAGESETUPDLG lppsd );
+ [DllImport(Lib_ComDlg32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("Commdlg.h")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool PageSetupDlg(ref PAGESETUPDLG lppsd);
+
+ ///
+ ///
+ /// [ PrintDlg is available for use in the operating systems specified in the Requirements section. It may be altered or
+ /// unavailable in subsequent versions. Instead, use PrintDlgEx or PageSetupDlg.]
+ ///
+ ///
+ /// Displays a Print Dialog Box or a Print Setup dialog box. The Print dialog box enables the user to specify the
+ /// properties of a particular print job.
+ ///
+ ///
+ ///
+ /// [in, out] Type: LPPRINTDLG
+ ///
+ /// A pointer to a PRINTDLG structure that contains information used to initialize the dialog box. When PrintDlg
+ /// returns, this structure contains information about the user's selections.
+ ///
+ ///
+ ///
+ /// Type: BOOL
+ ///
+ /// If the user clicks the OK button, the return value is nonzero. The members of the PRINTDLG structure pointed to by
+ /// the lppd parameter indicate the user's selections.
+ ///
+ ///
+ /// If the user canceled or closed the Print or Printer Setup dialog box or an error occurred, the return value is
+ /// zero. To get extended error information, use the CommDlgExtendedError function. If the user canceled or closed the dialog
+ /// box, CommDlgExtendedError returns zero; otherwise, it returns one of the following values.
+ ///
+ /// CDERR_FINDRESFAILURE
+ /// CDERR_INITIALIZATION
+ /// CDERR_LOADRESFAILURE
+ /// CDERR_LOADSTRFAILURE
+ /// CDERR_LOCKRESFAILURE
+ /// CDERR_MEMALLOCFAILURE
+ /// CDERR_MEMLOCKFAILURE
+ /// CDERR_NOHINSTANCE
+ /// CDERR_NOHOOK
+ /// CDERR_NOTEMPLATE
+ /// CDERR_STRUCTSIZE
+ /// PDERR_CREATEICFAILURE
+ /// PDERR_DEFAULTDIFFERENT
+ /// PDERR_DNDMMISMATCH
+ /// PDERR_GETDEVMODEFAIL
+ /// PDERR_INITFAILURE
+ /// PDERR_LOADDRVFAILURE
+ /// PDERR_NODEFAULTPRN
+ /// PDERR_NODEVICES
+ /// PDERR_PARSEFAILURE
+ /// PDERR_PRINTERNOTFOUND
+ /// PDERR_RETDEFFAILURE
+ ///
+ ///
+ ///
+ /// If the hook procedure (pointed to by the lpfnPrintHook or lpfnSetupHook member of the PRINTDLG structure)
+ /// processes the WM_CTLCOLORDLG message, the hook procedure must return a handle to the brush that should be used to paint
+ /// the control background.
+ ///
+ ///
+ /// Note that the values of hDevMode and hDevNames in PRINTDLG may change when they are passed into
+ /// PrintDlg. This is because these members are filled on both input and output.
+ ///
+ /// To switch printer selection, use PrintDlg or PrintDlgEx.
+ /// Windows Server 2003, Windows XP, and Windows 2000: To switch printer selection, use the Printer button
+ ///
+ /// Known issue: If PD_RETURNDC is set but PD_USEDEVMODECOPIESANDCOLLATE flag is not set, the PrintDlgEx
+ /// and PrintDlg functions return incorrect number of copies. To get the correct number of copies, ensure that the calling
+ /// application always uses PD_USEDEVMODECOPIESANDCOLLATE with PD_RETURNDC.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms646940(v=vs.85) BOOL WINAPI PrintDlg( _Inout_
+ // LPPRINTDLG lppd );
+ [DllImport(Lib_ComDlg32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("Commdlg.h")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool PrintDlg(ref PRINTDLG lppd);
+
+ ///
+ /// Displays a Print property sheet that enables the user to specify the properties of a particular print job. A Print
+ /// property sheet has a General page that contains controls similar to the Print dialog box. The property sheet can
+ /// also have additional application-specific and driver-specific property pages as well as the General page.
+ ///
+ ///
+ /// [in, out] Type: LPPRINTDLGEX
+ ///
+ /// A pointer to a PRINTDLGEX structure that contains information used to initialize the property sheet. When
+ /// PrintDlgEx returns, this structure contains information about the user's selections.
+ ///
+ /// This structure must be declared dynamically using a memory allocation function.
+ ///
+ ///
+ /// Type: HRESULT
+ ///
+ /// If the function succeeds, the return value is S_OK and the dwResultAction member of the PRINTDLGEX
+ /// structure contains one of the following values.
+ ///
+ ///
+ ///
+ /// Return code/value
+ /// Description
+ ///
+ /// -
+ /// PD_RESULT_APPLY 2
+ ///
+ /// 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 yet want to print. The PRINTDLGEX structure contains the information specified by the
+ /// user at the time the Apply button was clicked.
+ ///
+ ///
+ /// -
+ /// PD_RESULT_CANCEL 0
+ /// The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged.
+ ///
+ /// -
+ /// PD_RESULT_PRINT 1
+ /// The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user.
+ ///
+ ///
+ /// If the function fails, the return value may be one of the following COM error codes. For more information, see Error Handling.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// Insufficient memory.
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One or more arguments are invalid.
+ ///
+ /// -
+ /// E_POINTER
+ /// Invalid pointer.
+ ///
+ /// -
+ /// E_HANDLE
+ /// Invalid handle.
+ ///
+ /// -
+ /// E_FAIL
+ /// Unspecified error.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The values of hDevMode and hDevNames in PRINTDLGEX may change when they are passed into PrintDlgEx.
+ /// This is because these members are filled on both input and output. Be sure to free the memory allocated for these members
+ ///
+ ///
+ /// If PD_RETURNDC is set but PD_USEDEVMODECOPIESANDCOLLATE flag is not set, the PrintDlg and PrintDlgEx
+ /// functions return incorrect number of copies. To get the correct number of copies, ensure that the calling application always
+ /// uses PD_USEDEVMODECOPIESANDCOLLATE with PD_RETURNDC.
+ ///
+ /// For more information, see Print Property Sheet.
+ ///
+ // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms646942(v=vs.85) HRESULT WINAPI PrintDlgEx( _Inout_
+ // LPPRINTDLGEX lppd );
+ [DllImport(Lib_ComDlg32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("Commdlg.h")]
+ public static extern HRESULT PrintDlgEx(ref PRINTDLGEX lppd);
+
+ ///
+ /// Creates a system-defined modeless dialog box that lets the user specify a string to search for and a replacement string, as well
+ /// as options to control the find and replace operations.
+ ///
+ ///
+ /// Type: LPFINDREPLACE
+ ///
+ /// A pointer to a FINDREPLACE structure that contains information used to initialize the dialog box. The dialog box uses this
+ /// structure to send information about the user's input to your application. For more information, see the following Remarks section.
+ ///
+ ///
+ ///
+ /// Type: HWND
+ ///
+ /// If the function succeeds, the return value is the window handle to the dialog box. You can use the window handle to communicate
+ /// with the dialog box or close it.
+ ///
+ ///
+ /// If the function fails, the return value is NULL. To get extended error information, call the CommDlgExtendedError
+ /// function, which can return one of the following error codes:
+ ///
+ ///
+ ///
+ ///
+ /// The ReplaceText function does not perform a text replacement operation. Instead, the dialog box sends FINDMSGSTRING
+ /// registered messages to the window procedure of the owner window of the dialog box. When you create the dialog box, the
+ /// hwndOwner member of the FINDREPLACE structure is a handle to the owner window.
+ ///
+ ///
+ /// Before calling ReplaceText, you must call the RegisterWindowMessage function to get the identifier for the FINDMSGSTRING
+ /// message. The dialog box procedure uses this identifier to send messages when the user clicks the Find Next,
+ /// Replace, or Replace All buttons, or when the dialog box is closing. The lParam parameter of a FINDMSGSTRING
+ /// message contains a pointer to the FINDREPLACE structure. The Flags member of this structure indicates the event that
+ /// caused the message. Other members of the structure indicate the user's input.
+ ///
+ ///
+ /// If you create a Replace dialog box, you must also use the IsDialogMessage function in the main message loop of your
+ /// application to ensure that the dialog box correctly processes keyboard input, such as the TAB and ESC keys. The
+ /// IsDialogMessage function returns a value that indicates whether the Replace dialog box processed the message.
+ ///
+ ///
+ /// You can provide an FRHookProc hook procedure for a Replace dialog box. The hook procedure can process messages sent to
+ /// the dialog box. To enable a hook procedure, set the FR_ENABLEHOOK flag in the Flags member of the FINDREPLACE
+ /// structure and specify the address of the hook procedure in the lpfnHook member.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-replacetexta HWND ReplaceTextA( LPFINDREPLACEA Arg1 );
+ [DllImport(Lib_ComDlg32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("commdlg.h", MSDNShortId = "NF:commdlg.ReplaceTextA")]
+ public static extern HWND ReplaceText(ref FINDREPLACE Arg1);
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/ComDlg32/ComDlg32.cs b/PInvoke/ComDlg32/ComDlg32.cs
index 2debb4f0..99f2fb05 100644
--- a/PInvoke/ComDlg32/ComDlg32.cs
+++ b/PInvoke/ComDlg32/ComDlg32.cs
@@ -1,91 +1,367 @@
using System;
using System.Runtime.InteropServices;
+using static Vanara.PInvoke.Kernel32;
+using static Vanara.PInvoke.User32;
namespace Vanara.PInvoke
{
/// Items from the ComDlg32.dll
public static partial class ComDlg32
{
- private const string Lib_ComDlg32 = "ComDlg32.dll";
+ ///
+ /// 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,
+ }
///
- ///
- /// [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.]
- ///
- ///
- /// Receives notification messages sent from the dialog box. The function also receives messages for any additional controls that
- /// you defined by specifying a child dialog template. The OFNHookProc hook procedure is an application-defined or library-defined
- /// callback function that is used with the Explorer-style Open and Save As dialog boxes.
- ///
- ///
- /// The LPOFNHOOKPROC type defines a pointer to this callback function. OFNHookProc is a placeholder for the
- /// application-defined function name.
- ///
+ /// 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.
///
- ///
- /// A handle to the child dialog box of the Open or Save As dialog box. Use the GetParent function to get the handle
- /// to the Open or Save As dialog box.
- ///
- /// The identifier of the message being received.
- /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter.
- ///
- /// Additional information about the message. The exact meaning depends on the value of the Arg2 parameter. If the Arg2 parameter
- /// indicates the WM_INITDIALOG message, Arg4 is a pointer to an OPENFILENAME structure containing the values specified when the
- /// dialog box was created.
- ///
- ///
- /// If the hook procedure returns zero, the default dialog box procedure processes the message.
- /// If the hook procedure returns a nonzero value, the default dialog box procedure ignores the message.
- ///
- /// For the CDN_SHAREVIOLATION and CDN_FILEOK notification messages, the hook procedure should return a nonzero value to indicate
- /// that it has used the SetWindowLong function to set a nonzero DWL_MSGRESULT value.
- ///
- ///
- ///
- ///
- /// If you do not specify the OFN_EXPLORER flag when you create an Open or Save As dialog box, and you want a
- /// hook procedure, you must use an old-style OFNHookProcOldStyle hook procedure. In this case, the dialog box will have the
- /// old-style user interface.
- ///
- ///
- /// When you use the GetOpenFileName or GetSaveFileName functions to create an Explorer-style Open or Save As dialog
- /// box, you can provide an OFNHookProc hook procedure. To enable the hook procedure, use the OPENFILENAME structure that you passed
- /// to the dialog creation function. Specify the pointer to the hook procedure in the lpfnHook member and specify the
- /// OFN_ENABLEHOOK flag in the Flags member.
- ///
- ///
- /// If you provide a hook procedure for an Explorer-style common dialog box, the system creates a dialog box that is a child of the
- /// default dialog box. The hook procedure acts as the dialog procedure for the child dialog. This child dialog is based on the
- /// template you specified in the OPENFILENAME structure, or it is a default child dialog if no template is specified. The child
- /// dialog is created when the default dialog procedure is processing its WM_INITDIALOG message. After the child dialog processes
- /// its own WM_INITDIALOG message, the default dialog procedure moves the standard controls, if necessary, to make room for
- /// any additional controls of the child dialog. The system then sends the CDN_INITDONE notification message to the hook procedure.
- ///
- ///
- /// The hook procedure does not receive messages intended for the standard controls of the default dialog box. You can subclass the
- /// standard controls, but this is discouraged because it may make your application incompatible with later versions. However, the
- /// Explorer-style common dialog boxes provide a set of messages that the hook procedure can use to monitor and control the dialog.
- /// These include a set of notification messages sent from the dialog, as well as messages that you can send to retrieve information
- /// from the dialog. For a complete list of these messages, see Explorer-Style Hook Procedures.
- ///
- ///
- /// If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid brush handle to painting the background of
- /// the dialog box. In general, if it processes any WM_CTLCOLOR* message, it must return a valid brush handle to painting the
- /// background of the specified control.
- ///
- ///
- /// Do not call the EndDialog function from the hook procedure. Instead, the hook procedure can call the PostMessage function to
- /// post a WM_COMMAND message with the IDCANCEL value to the dialog box procedure. Posting IDCANCEL closes the dialog
- /// box and causes the dialog box function to return FALSE. If you need to know why the hook procedure closed the dialog box,
- /// you must provide your own communication mechanism between the hook procedure and your application.
- ///
- ///
- // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nc-commdlg-lpofnhookproc LPOFNHOOKPROC Lpofnhookproc; UINT_PTR
- // Lpofnhookproc( HWND Arg1, UINT Arg2, WPARAM Arg3, LPARAM Arg4 ) {...}
- [PInvokeData("commdlg.h", MSDNShortId = "NC:commdlg.LPOFNHOOKPROC")]
- [UnmanagedFunctionPointer(CallingConvention.Winapi)]
- public delegate IntPtr LPOFNHOOKPROC(HWND Arg1, uint Arg2, IntPtr Arg3, IntPtr Arg4);
+ [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
@@ -296,64 +572,1229 @@ namespace Vanara.PInvoke
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,
+ }
+
///
- ///
- /// [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.]
- ///
- ///
- /// Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or set of files to be opened.
- ///
+ /// 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.
+ ///
+ ///
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string 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.
+ ///
+ ///
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string 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.
+ ///
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string 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.
///
- ///
- /// Type: LPOPENFILENAME
- ///
- /// A pointer to an OPENFILENAME structure that contains information used to initialize the dialog box. When GetOpenFileName
- /// returns, this structure contains information about the user's file selection.
- ///
- ///
- ///
- /// Type: BOOL
- ///
- /// If the user specifies a file name and clicks the OK button, the return value is nonzero. The buffer pointed to by the
- /// lpstrFile member of the OPENFILENAME structure contains the full path and file name specified by the user.
- ///
- ///
- /// If the user cancels or closes the Open dialog box or an error occurs, the return value is zero. To get extended error
- /// information, call the CommDlgExtendedError function, which can return one of the following values.
- ///
- ///
///
- ///
- /// The Explorer-style Open dialog box provides user-interface features that are similar to the Windows Explorer. You can
- /// provide an OFNHookProc hook procedure for an Explorer-style Open dialog box. To enable the hook procedure, set the
- /// OFN_EXPLORER and OFN_ENABLEHOOK flags in the Flags member of the OPENFILENAME structure and specify the
- /// address of the hook procedure in the lpfnHook member.
- ///
- ///
- /// Windows continues to support the old-style Open dialog box for applications that want to maintain a user-interface
- /// consistent with the old-style user-interface. To display the old-style Open dialog box, enable an OFNHookProcOldStyle
- /// hook procedure and ensure that the OFN_EXPLORER flag is not set.
- ///
- /// To display a dialog box that allows the user to select a directory instead of a file, call the SHBrowseForFolder function.
- /// Note, when selecting multiple files, the total character limit for the file names depends on the version of the function.
- ///
- /// -
- /// ANSI: 32k limit
- ///
- /// -
- /// Unicode: no restriction
- ///
- ///
- /// Examples
- /// For an example, see Opening a File.
+ /// 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/nf-commdlg-getopenfilenamea BOOL GetOpenFileNameA( LPOPENFILENAMEA
- // Arg1 );
- [DllImport(Lib_ComDlg32, SetLastError = false, CharSet = CharSet.Auto)]
- [PInvokeData("commdlg.h", MSDNShortId = "NF:commdlg.GetOpenFileNameA")]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool GetOpenFileName(ref OPENFILENAME Arg1);
+ // 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;
+ }
///
///
@@ -887,6 +2328,7 @@ namespace Vanara.PInvoke
/// controls of the default dialog box.
///
///
+ [MarshalAs(UnmanagedType.FunctionPtr)]
public LPOFNHOOKPROC lpfnHook;
///
@@ -935,46 +2377,1198 @@ namespace Vanara.PInvoke
public uint FlagsEx;
}
- /*
- CHOOSECOLORA
- CHOOSECOLORW
- CHOOSEFONTA
- CHOOSEFONTW
- DEVNAMES
- FINDREPLACEA
- FINDREPLACEW
- OFNOTIFYA
- OFNOTIFYEXA
- OFNOTIFYEXW
- OFNOTIFYW
- PAGESETUPDLGA
- PAGESETUPDLGW
- PRINTDLGA
- PRINTDLGEXA
- PRINTDLGEXW
- PRINTDLGW
- PRINTPAGERANGE
-
- LPCCHOOKPROC
- LPCFHOOKPROC
- LPFRHOOKPROC
- LPPAGEPAINTHOOK
- LPPAGESETUPHOOK
- LPPRINTHOOKPROC
- LPSETUPHOOKPROC
+ ///
+ /// 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;
- IPrintDialogCallback
- IPrintDialogServices
+ ///
+ /// 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;
- CommDlgExtendedError
- FindTextA
- FindTextW
- GetFileTitleA
- GetFileTitleW
- GetSaveFileNameA
- GetSaveFileNameW
- ReplaceTextA
- ReplaceTextW
- */
+ ///
+ /// 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 System.Drawing.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;
+ }
}
}
\ No newline at end of file
diff --git a/PInvoke/ComDlg32/Vanara.PInvoke.ComDlg32.csproj b/PInvoke/ComDlg32/Vanara.PInvoke.ComDlg32.csproj
index e7201fdd..f9d2a8d3 100644
--- a/PInvoke/ComDlg32/Vanara.PInvoke.ComDlg32.csproj
+++ b/PInvoke/ComDlg32/Vanara.PInvoke.ComDlg32.csproj
@@ -22,6 +22,8 @@ OPENFILENAME
+
+
\ No newline at end of file
diff --git a/UnitTests/PInvoke/ComDlg32/ComDlg32Tests.cs b/UnitTests/PInvoke/ComDlg32/ComDlg32Tests.cs
index ec7b2123..b1ca2a36 100644
--- a/UnitTests/PInvoke/ComDlg32/ComDlg32Tests.cs
+++ b/UnitTests/PInvoke/ComDlg32/ComDlg32Tests.cs
@@ -3,6 +3,7 @@ using NUnit.Framework.Internal;
using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.ComDlg32;
+using static Vanara.PInvoke.User32;
namespace Vanara.PInvoke.Tests
{
@@ -19,6 +20,19 @@ namespace Vanara.PInvoke.Tests
{
}
+ [Test]
+ public void ChooseColorTest()
+ {
+ var cc = new CHOOSECOLOR
+ {
+ lStructSize = (uint)Marshal.SizeOf(typeof(CHOOSECOLOR)),
+ rgbResult = System.Drawing.Color.Red,
+ Flags = CC.CC_RGBINIT,
+ hwndOwner = GetDesktopWindow()
+ };
+ Assert.That(ChooseColor(ref cc), Is.True);
+ }
+
[Test]
public void GetOpenFileNameTest()
{
@@ -33,8 +47,45 @@ namespace Vanara.PInvoke.Tests
nFilterIndex = 1,
Flags = OFN.OFN_PATHMUSTEXIST | OFN.OFN_FILEMUSTEXIST
};
- Assert.That(GetOpenFileName(ref ofn), ResultIs.Successful);
+ Assert.That(GetOpenFileName(ref ofn), Is.True);
Assert.That(ofn.lpstrFilter.Length, Is.GreaterThan(0));
}
+
+ [Test]
+ public void FindTextTest()
+ {
+ using var wnd = new DlgWin(RegisterWindowMessage(FINDMSGSTRING));
+ var fwch = new char[261];
+ var fw = new string(fwch);
+ var fr = new FINDREPLACE
+ {
+ lStructSize = (uint)Marshal.SizeOf(typeof(FINDREPLACE)),
+ hwndOwner = wnd.MessageWindowHandle,
+ lpstrFindWhat = fw,
+ wFindWhatLen = (ushort)fwch.Length,
+ };
+ Assert.That(wnd.hdlg = FindText(ref fr), Is.True);
+ }
+
+ class DlgWin : SystemEventHandler
+ {
+ uint rmsg;
+ internal HWND hdlg = default;
+
+ public DlgWin(uint m)
+ {
+ rmsg = m;
+ }
+
+ protected override bool PreprocessMessage(in MSG msg) => IsDialogMessage(hdlg, msg);
+
+ protected override bool MessageFilter(HWND hwnd, uint msg, IntPtr wParam, IntPtr lParam, out IntPtr lReturn)
+ {
+ lReturn = default;
+ if (msg == rmsg)
+ return true;
+ return false;
+ }
+ }
}
}
\ No newline at end of file