MFC ActiveX Controls: Returning Error Codes From a Method
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at MFC ActiveX Controls: Returning Error Codes From a Method.
This article describes how to return error codes from an ActiveX control method.
To indicate that an error has occurred within a method, you should use the COleControl::ThrowError member function, which takes an SCODE
(status code) as a parameter. You can use a predefined SCODE
or define one of your own.
Note
ThrowError
is meant to be used only as a means of returning an error from within a property's Get or Set function or an automation Method. These are the only times that the appropriate exception handler will be present on the stack.
Helper functions exist for the most common predefined SCODE
s, such as COleControl::SetNotSupported, COleControl::GetNotSupported, and COleControl::SetNotPermitted.
For a list of predefined SCODE
s and instructions on defining custom SCODE
s, see the section Handling Errors in Your ActiveX Control in ActiveX Controls: Advanced Topics.
For more information on reporting exceptions in other areas of your code, see COleControl::FireError and the section Handling Errors in Your ActiveX Control in ActiveX Controls: Advanced Topics.