


|
Personal page of Konjengbam |
|
“Bluetooth adopter, technology enabler and innovative thinking” |

|
This ATL server (source provider) is then compiled to produce EventSource.tlb and EventSource.dll (here, an InprocServer in this example). MFC Clients can later use the TLB file to import C++ wrappers for the InprocServer object to assist invoking the Dispatch methods of ITick interface. Implementing the ClientThe Client is implemented using MFC, as a dialog-based application. It has elementary functionalities as shown in figure below, primarily to start the InProcServer instance and making calls to ITick methods via the Dispatcher wrappers and then subsequently, hooks up for ATL advise. |
|
Fig. A2 - The Client GUI
The sink implementation for the COM Client is done as a simple C++ sink object (without any composite control etc.). This is done because no other services are interested in our Client application. The code below shows how the sink interface is implemented as a simple C++ class. |
|
Contd. ( Back << ) |
|
In above, there is a dependency relationship with the Dialog's window object. This was done to print something from our event handler method.
Finally, the InProcServer is instantiated in the following way. Also, note how we start subscribing for ATL events from the server. |
|
Upon clicking "Close" to terminate the application, we also make sure we close all reference calls to the server instance, but before that perform ATL Unadvise from the server object. Download the full source code here. |
Skype Plugin using COM DllFollowing this tutorial, as a next step, one can go through the Skype plugin example that I coded as COM library sometime ago and see how the same is re-used in a simple Dialog based MFC application. The interface IDL file looks somewhat like the following below: |
|
// AfSkypePlug.idl : IDL source for AfSkypePlug.dll //
// This file will be processed by the MIDL tool to // produce the type library (AfSkypePlug.tlb) and marshalling code.
import "oaidl.idl"; import "ocidl.idl";
[ object, uuid(BE9AA74B-AA0B-4DF2-9C12-1781563913F0), dual, helpstring("ISkype Interface"), pointer_default(unique) ] interface ISkype : IDispatch { [id(1), helpstring("method Connect")] HRESULT Connect(); [id(2), helpstring("method Disconnect")] HRESULT Disconnect(); [id(3), helpstring("method SendCmd")] HRESULT SendCmd([in] BSTR Cmd); };
[ uuid(54A78D3E-F323-42CE-AD45-4F51E39D27E2), version(1.0), helpstring("AfSkypePlug 1.0 Type Library") ] library AFSKYPEPLUGLib { importlib("stdole32.tlb"); importlib("stdole2.tlb");
[ uuid(2CCD385B-57D4-4AFB-BA94-DA4038B150DB), helpstring("_ISkypeEvents Interface") ] dispinterface _ISkypeEvents { properties: methods: [id(1), helpstring("method OnSkypeConnected")] HRESULT OnSkypeConnected([in] VARIANT vBoolStatus); [id(2), helpstring("method OnSkypeDisconnected")] HRESULT OnSkypeDisconnected(); [id(3), helpstring("method OnSkypeIndMsg")] HRESULT OnSkypeIndMsg([in] BSTR Msg); };
[ uuid(1E7617A4-7FDD-4A35-8E6C-1E803AAB82B4), helpstring("Skype Class") ] coclass Skype { [default] interface ISkype; [default, source] dispinterface _ISkypeEvents; }; }; |
|
Click here to download the entire library and test application implementation. |