diff --git a/PInvoke/ComDlg32/ComDlg32.Funcs.cs b/PInvoke/ComDlg32/ComDlg32.Funcs.cs index 1c3113db..2d7c2fcd 100644 --- a/PInvoke/ComDlg32/ComDlg32.Funcs.cs +++ b/PInvoke/ComDlg32/ComDlg32.Funcs.cs @@ -1107,7 +1107,7 @@ namespace Vanara.PInvoke // 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(); + public static extern ERR CommDlgExtendedError(); /// /// Creates a system-defined modeless Find dialog box that lets the user specify a string to search for and options to use diff --git a/PInvoke/ComDlg32/ComDlg32.cs b/PInvoke/ComDlg32/ComDlg32.cs index 68991c51..073b60a4 100644 --- a/PInvoke/ComDlg32/ComDlg32.cs +++ b/PInvoke/ComDlg32/ComDlg32.cs @@ -2,6 +2,7 @@ using System; using System.Runtime.InteropServices; using Vanara.Extensions; using Vanara.InteropServices; + using static Vanara.PInvoke.Kernel32; using static Vanara.PInvoke.User32; @@ -61,6 +62,209 @@ namespace Vanara.PInvoke CC_SOLIDCOLOR = 0x00000080, } + /// + /// An error code returned by the CommDlgExtendedError function. + /// + /// + /// + /// + /// Error code + /// Meaning + /// + /// + /// CDERR + /// General error codes that can be returned for any of the common dialog box functions. + /// + /// + /// PDERR + /// Error codes returned for the PrintDlg function. + /// + /// + /// + /// + /// CFERR + /// Error codes returned for the ChooseFont function. + /// + /// + /// FNERR + /// Error codes returned for the GetOpenFileName and GetSaveFileName functions. + /// + /// + /// FRERR + /// Error codes returned for the FindText and ReplaceText functions. + /// + /// + /// + [PInvokeData("cderr.h")] + public enum ERR : uint + { + /// + /// 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_DIALOGFAILURE = 0xFFFF, + + /// + /// The common dialog box function failed to find a specified resource. + /// + CDERR_FINDRESFAILURE = 0x0006, + + /// + /// The common dialog box function failed during initialization. This error often occurs when sufficient memory is not available. + /// + CDERR_INITIALIZATION = 0x0002, + + /// + /// The common dialog box function failed to load a specified resource. + /// + CDERR_LOADRESFAILURE = 0x0007, + + /// + /// The common dialog box function failed to load a specified string. + /// + CDERR_LOADSTRFAILURE = 0x0005, + + /// + /// The common dialog box function failed to lock a specified resource. + /// + CDERR_LOCKRESFAILURE = 0x0008, + + /// + /// The common dialog box function was unable to allocate memory for internal structures. + /// + CDERR_MEMALLOCFAILURE = 0x0009, + + /// + /// The common dialog box function was unable to lock the memory associated with a handle. + /// + CDERR_MEMLOCKFAILURE = 0x000A, + + /// + /// 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_NOHINSTANCE = 0x0004, + + /// + /// 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_NOHOOK = 0x000B, + + /// + /// 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_NOTEMPLATE = 0x0003, + + /// + /// The RegisterWindowMessage function returned an error code when it was called by the common dialog box function. + /// + CDERR_REGISTERMSGFAIL = 0x000C, + + /// + /// The lStructSize member of the initialization structure for the corresponding common dialog box is invalid. + /// + CDERR_STRUCTSIZE = 0x0001, + + /// + /// The PrintDlg function failed when it attempted to create an information context. + /// + PDERR_CREATEICFAILURE = 0x100A, + + /// + /// 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_DEFAULTDIFFERENT = 0x100C, + + /// + /// The data in the DEVMODE and DEVNAMES structures describes two different printers. + /// + PDERR_DNDMMISMATCH = 0x1009, + + /// + /// The printer driver failed to initialize a DEVMODE structure. + /// + PDERR_GETDEVMODEFAIL = 0x1005, + + /// + /// 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_INITFAILURE = 0x1006, + + /// + /// The PrintDlg function failed to load the device driver for the specified printer. + /// + PDERR_LOADDRVFAILURE = 0x1004, + + /// + /// A default printer does not exist. + /// + PDERR_NODEFAULTPRN = 0x1008, + + /// + /// No printer drivers were found. + /// + PDERR_NODEVICES = 0x1007, + + /// + /// The PrintDlg function failed to parse the strings in the [devices] section of the WIN.INI file. + /// + PDERR_PARSEFAILURE = 0x1002, + + /// + /// The [devices] section of the WIN.INI file did not contain an entry for the requested printer. + /// + PDERR_PRINTERNOTFOUND = 0x100B, + + /// + /// The PD_RETURNDEFAULT flag was specified in the Flags member of the PRINTDLG structure, but the hDevMode or hDevNames member was not NULL. + /// + PDERR_RETDEFFAILURE = 0x1003, + + /// + /// The PrintDlg function failed to load the required resources. + /// + PDERR_SETUPFAILURE = 0x1001, + + /// + /// The size specified in the nSizeMax member of the CHOOSEFONT structure is less than the size specified in the nSizeMin member. + /// + CFERR_MAXLESSTHANMIN = 0x2002, + + /// + /// No fonts exist. + /// + CFERR_NOFONTS = 0x2001, + + /// + /// 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_BUFFERTOOSMALL = 0x3003, + + /// + /// A file name is invalid. + /// + FNERR_INVALIDFILENAME = 0x3002, + + /// + /// An attempt to subclass a list box failed because sufficient memory was not available. + /// + FNERR_SUBCLASSFAILURE = 0x3001, + + /// + /// A member of the FINDREPLACE structure points to an invalid buffer. + /// + FRERR_BUFFERLENGTHZERO = 0x4001, + } + /// /// 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. @@ -3564,4 +3768,4 @@ namespace Vanara.PInvoke public uint nToPage; } } -} \ No newline at end of file +}