The following error macros are used in conjunction with property pages. They act on errors returned by control properties and methods, and assume that the control has thrown an exception before returning the error code. The exception information is used to compose the error message that is displayed to the user.
Controls do not throw exceptions for the E_OUTOFMEMORY error code, so the error message for this code is defined by the IDS_ERR_OUTOFMEMORY string resource. Error codes returned without exceptions are displayed with the generic error message defined by the IDS_ERR_FORMAT string resource.
The INVALID_ENTRY_* macros use the string resource defined by the IDS_ERR_INVALIDENTRY string ID to format the error message.
Macro | Description |
ERROR_ON_FAILURE(hr) | Test whether hr is an error code; if so, display the error. Execution continues to the next statement. |
IF_SUCCEEDED(hr) | Test whether hr is an error code; if so, display the error. Otherwise, execute the statement block. |
ON_ERROR_RETURN(hr, ret) | Test whether hr is an error code; if so, display the error and return ret. Otherwise, continue executing the next statement. |
ON_ERROR_GOTO(hr, label) | Test whether hr is an error code; if so, display the error and goto label. Otherwise, continue executing the next statement. |
ON_ERROR_EDIT_GOTO(hr, id, label) | Test whether hr is an error code; if so, display the error, set focus to the edit control identified by id, and goto label. Otherwise, continue executing the next statement. |
ON_ERROR_EDIT_RETURN(hr, id, ret) | Test whether hr is an error code; if so, display the error, set focus to the edit control identified by id, and return ret. Otherwise, continue executing the next statement. |
ON_INVALID_ENTRY_RETURN(f, id, ret) | If f is TRUE, then continue executing the next statement. Otherwise, display an invalid entry error message box, set focus to the edit control identified by id, and return ret. The control prior to the edit control must be a static text control because its text is used in the error message to identify the invalid property. |
ON_INVALID_ENTRY_GOTO(f, id, label) | If f is TRUE, then continue executing the next statement. Otherwise, display an invalid entry error message box, set focus to the edit control identified by id, and goto label. The control prior to the edit control must be a static text control because its text is used in the error message to identify the invalid property. |