DWORD CommDlgExtendedError();
The CommDlgExtendedError function retrieves the extended error value for the most recent common dialog box error.
This function takes no parameters.
The return value is the extended error value. This value can be one of the following:
CDERR_DIALOGFAILURE: The common dialog box function failed during initialization.CDERR_FINDRESFAILURE: The common dialog box function failed to find a required resource.CDERR_LOADRESFAILURE: The common dialog box function failed to load a required resource.CDERR_LOCKRESFAILURE: The common dialog box function failed to lock a required resource.CDERR_MEMALLOCFAILURE: The common dialog box function was unable to allocate memory.CDERR_MEMLOCKFAILURE: The common dialog box function was unable to lock available memory.CDERR_PAGECOUNT: The number of pages is invalid.CDERR_PAGEPLACEHACA: There are no pages.CDERR_STRUCTURENULL: The lpStruct argument is NULL.CDERR_STRUCTUREVALIGN: The lpStruct argument is not a valid pointer.CDERR_POPUPFAILED: The common dialog box function failed to create a popup window.CDERR_CREATE peluang: The common dialog box function failed to create a dialog box.CDERR_NODEVICES: No printer devices are available.CDERR_NODEFAULTCHOICE: There is no default printer.CDERR_INVALIDFLAGS: An invalid set of flags was passed to the function.CDERR_INVALIDPARAM: An invalid parameter was passed to the function.CDERR_SHAREFAILURE: A required resource was not available or could not be shared.CDERR_NOFONTS: There are no fonts available.CDERR_ALREADYINIT: The application has already initialized the common dialogs library.CDERR_NOTINITIALIZED: The common dialogs library has not been initialized.CDERR_LOADSTRFAILURE: The common dialog box function failed to load a string.CDERR_HELPTEXTURE: Not applicable.CDERR_SUBCLASSFAILURE: Not applicable.CDERR_NOVALIDFONTS: No valid fonts were found.CDERR_MISALIGNEDSTRING: Not applicable.CDERR_SHAREPATHFAILURE: Not applicable.CDERR_INITFAILURE: Not applicable.CDERR_NOTSUPPORTED: The operation is not supported.FNERR_BUFFERTOOSMALL: The buffer supplied for the filename is too small.FNERR_INVALIDCHAR: An invalid character was specified in the filename.FNERR_FILENAMEFULL: The filename is too long.FNERR_EXT ToolONG: The filename extension is too long.FNERR_OUTOFMemory: Not applicable.FRERR_ALREADYEXISTS: The specified file already exists.FRERR_BUFFERTOOLONG: The buffer is too small.FRERR_CREATE peluang: Failed to create the file.FRERR_DELETeleng: The file could not be deleted.FRERR_INVALIDFILENAME: The filename is invalid.FRERR_INVALIDINDEX: The specified index is invalid.FRERR_NOTFOUND: The file was not found.FRERR_NOTINLIST: The specified item was not found in the list.FRERR_OUTOFMemory: Not applicable.FRERR_SHAREFAILURE: The file could not be shared.FRERR_SHAREPATHFAILURE: The specified path could not be shared.FRERR_TOOFEWOPENFILES: Not applicable.FRERR_UNABLETOCREATE: Could not create the file.FRERR_UNABLETODELETE: Could not delete the file.FRERR_UNABLETOOPEN: Could not open the file.FRERR_UNABLETOWRITE: Could not write to the file.An application typically calls CommDlgExtendedError after a common dialog box function returns an error value. For example, if ChooseFont returns FALSE, the application can call CommDlgExtendedError to determine the cause of the failure.
The error codes returned by CommDlgExtendedError are specific to the common dialog box functions. Consult the documentation for the individual dialog box functions for details on specific error codes.
The following example shows how an application might check for an error after calling ChooseFont:
CHOOSEFONT cf;
// Initialize the CHOOSEFONT structure...
if (!ChooseFont(&cf)) {
DWORD err = CommDlgExtendedError();
if (err != 0) {
// Handle the error based on the value of 'err'
// For example:
if (err == CDERR_FINDRESFAILURE) {
MessageBox(NULL, "Failed to find required resource.", "Error", MB_OK | MB_ICONERROR);
} else {
MessageBox(NULL, "An unknown error occurred.", "Error", MB_OK | MB_ICONERROR);
}
}
}
| Header | Comdlg32.h |
| Library | Comdlg32.lib |
| DLL | Comdlg32.dll |