Re: share event interface
On Jun 6, 3:50 pm, Sue <jean....@gmail.com> wrote:
On Jun 6, 3:39 pm, Sue <jean....@gmail.com> wrote:
On Jun 6, 4:54 am, "Igor Tandetnik" <itandet...@mvps.org> wrote:
"Sue" <jean....@gmail.com> wrote in message
news:1181108572.451801.131710@k79g2000hse.googlegroups.com
I have 2 component and I want them to fire the same event to
application using connection point. Is it possible to share the event
interface, in other words, both component will implement connection
point on the same source event interface?
Yes.
Can anyone tell me how to do
this?
If both components are implemented in the same server, you don't need to
do anything special. Just describe both in the same IDL file, together
with the shared event interface.
If the two components are in separate servers, then put the shared
interface into its own IDL file and compile it into a type library. Then
importlib this type library from each component's IDL.
--
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
I create a idl file and put the shared interfaces inside the idl file,
but when I run the midl trying to generate the .tlb file, it's not
generated. I can't find the .tlb file anywhere. But it generate
the .h and .c file fine. Any idea? the following is my idl file and
the command I used to generate the type library.
//plugincomm.idl
[
object,
uuid(50E189C6-1805-4E38-A3CB-8DB7FCC5FD01),
dual,
nonextensible,
helpstring("ISAProcessHandler Interface"),
pointer_default(unique)
]
interface ISAProcessHandler : IDispatch{
import "dispex.idl" ;
[id(1), helpstring("method Process")] HRESULT Process([in] LONG hWnd,
[in] LONG ptX, [in] LONG ptY, [out,retval] BSTR* pbstrText);
[id(2), helpstring("method GetPriority")] HRESULT
GetPriority([out,retval] SHORT* priority);
};
[
uuid(4F576024-FCA8-4068-9C21-98F8BAF4C4A1),
helpstring("ISAProcessEvent interface")
]
interface ISAProcessEvent : IDispatch
{
[id(1), helpstring("method ProcessOver")] HRESULT
ProcessOver( [out,retval] BSTR* pbstrText );
};
// command line to run midl
midl /tlb plugincomm.tlb /h plugincomm.h /iid plugincomm.c
plugincomm.idl- Hide quoted text -
- Show quoted text -
Sorry, I figure it out. I modified my idl file as following, then it
generate the .tlb file. Does this .idl file looks ok?- Hide quoted text -
- Show quoted text -
Now I have another problem. The following is what I did:
1. I modfied my common idl file as the following and build the type
library plugincomm.tlb
enum PRORITY
{
LOW = 400,
MID = 200,
HIGH = 100
};
//process interface
[
object,
uuid(50E189C6-1805-4E38-A3CB-8DB7FCC5FD01),
dual,
nonextensible,
helpstring("ISAProcessHandler Interface"),
pointer_default(unique)
]
interface ISAProcessHandler : IDispatch{
import "dispex.idl" ;
[id(1), helpstring("method Process")] HRESULT Process([in] LONG hWnd,
[in] LONG ptX, [in] LONG ptY, [out,retval] BSTR* pbstrText);
[id(2), helpstring("method GetPriority")] HRESULT
GetPriority([out,retval] SHORT* priority);
};
//event interface
[
uuid(4F576024-FCA8-4068-9C21-98F8BAF4C4A1),
helpstring("ISAProcessEvent interface")
]
interface ISAProcessEvent : IDispatch
{
[id(1), helpstring("method ProcessOver")] HRESULT
ProcessOver( [out,retval] BSTR* pbstrText );
};
[
uuid(988C1EA5-C483-4a47-BB4C-2D9A1640F123),
version(1.0),
helpstring("PluginComm 1.0 Type Library")
]
library PluginCommLib
{
importlib("stdole2.tlb");
};
2. I modified my inproc server's idl file as following
import "oaidl.idl";
import "ocidl.idl";
import "..\include\pluginComm.idl";
[
uuid(ADE2FF59-F08C-4E6B-9B3E-C8A60A8ACC2B),
version(1.0),
helpstring("StaticProcHandlerPlugin 1.0 Type Library")
]
library StaticProcHandlerPluginLib
{
importlib("stdole2.tlb");
importlib("..\\lib\\plugincomm.tlb");
[
uuid(89823E54-5ADE-45D7-8BB0-276FED4BB57E),
helpstring("StaticProcHandler Class")
]
coclass StaticProcHandler
{
[default] interface ISAProcessHandler;
[default, source] interface ISAProcessEvent;
};
};
3. I compile my project, it compiles fine.
4. Then right click my class, then "add connection point". The
PluginCommLib<1.0> showned under the available libraries with the
ISAProcessEvent as the source interface, I add the interface, then
click finish.
5.Now a message box said"Error in OnFinish: Failed to return new code
element. possible syntax error. New Element Name:"".
What did I do wrong? Thanks.