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);
}
}