Re: can event handler call event source passed as connection point parameter?
Here they are:
[ object, uuid(...), dual, nonextensible, pointer_default(unique) ]
interface IServer : IDispatch
{
[id(11)] HRESULT SomeMethod();
};
In library section:
[ uuid(...) ]
dispinterface _IServerEvents
{
methods:
[id(3)] void OnSomeEvent([in] IServer * ptr, [in] long
param);
};
[ uuid(...), noncreatable ]
coclass Server
{
[default] interface IServer;
[default, source] dispinterface _IServerEvents;
};
Thanks a lot.
Igor Tandetnik wrote:
Xudong <chenxudongsg@gmail.com> wrote:
What's weird here is that if I do a redundant QueryInterface on the
pointer for its own type, the code runs normal! The code is similar to
following:
// event source in free threaded DLL
class CServer ... {
Fire_OnSomeEvent(IServer* ptr) { // ATL generated
...
HRESULT hr = Invoke(...);
...
}
SomeMethod() {}
};
// event handler in apartment threaded EXE
class CClient ... {
void __stdcall OnSomeEvent(IServer * ptr) {
ptr->QueryInterface(IID_IServer, (void**)&ptr); // line X
ptr->SomeMethod(): // line Y
}
};
With line X, everything works fine and line Y does call through
SomeMethod().
Show the definition of IServer. What kind of interface is it - dual,
automation, custom? Show the definition of OnSomeEvent: what type
parameter is it declared to have?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925