Microsoft Learn

CommDlgExtendedError Function

DWORD CommDlgExtendedError();

The CommDlgExtendedError function retrieves the extended error value for the most recent common dialog box error.

Parameters

This function takes no parameters.

Return Value

The return value is the extended error value. This value can be one of the following:

Remarks

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.

Important

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.

Example

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

Requirements

Header Comdlg32.h
Library Comdlg32.lib
DLL Comdlg32.dll