
Throwing an Error from ATL COM controls method
I don't really get it. If you want to raise an exception, you have to be
at least executing... At this point you are not executing - the client
does in its event sink.
Anyway, you cannot throw exceptions across COM interface boundaries.
Instead, you return a failure HRESULT from the method. You can also
optionally provide some information about the error by implementing
ISupportErrorInfo, confirming your interface supports rich information
in the implementation of its only method and then setting the error info
via CComCoClass::Error() or AtlReportError() immediately prior to
returning with the failure HRESULT from your method.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
Quote:
> Hi,
> Does any one know of how to throw an exception or error from a ATL COM
> controls method, when an event of this control occurs..
> In detail, assume that an atl com control has a method say Method1()
> and an event Event1(). Now Method1() is being invoked by the user, and
> the event1() also is triggerred, when event1() is triggered and at that
> time if the execution is inside Method1(), how can the method throw
> exception when the event is triggered while it is in execution.....
> Immediate help is greatly appreciated........
> Thanks in Advance.........
> Aruna.
> Sent via Deja.com http://www.deja.com/
> Before you buy.