source: trunk/Utilities/VbsEvents/Foo.h @ 937

Last change on this file since 937 was 81, checked in by roman, 12 years ago
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2008-2012
3// Created by Roman Ryltsov roman@alax.info
4//
5// $Id: Foo.h 81 2012-07-30 16:45:31Z roman $
6
7#pragma once
8
9#include <atlstr.h>
10#include "VbsEvents_i.h"
11#include "_IFooEvents_CP.h"
12
13#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
14#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
15#endif
16
17using namespace ATL;
18
19////////////////////////////////////////////////////////////
20// CFoo
21
22class ATL_NO_VTABLE CFoo :
23        public CComObjectRootEx<CComSingleThreadModel>,
24        public CComCoClass<CFoo, &CLSID_Foo>,
25        public IConnectionPointContainerImpl<CFoo>,
26        public CProxy_IFooEvents<CFoo>,
27        public IDispatchImpl<IFoo>,
28        public IProvideClassInfo2Impl<&__uuidof(Foo), &__uuidof(_IFooEvents)>
29{
30public:
31
32DECLARE_REGISTRY_RESOURCEID(IDR_FOO)
33
34DECLARE_PROTECT_FINAL_CONSTRUCT()
35
36BEGIN_COM_MAP(CFoo)
37        COM_INTERFACE_ENTRY(IFoo)
38        COM_INTERFACE_ENTRY(IDispatch)
39        COM_INTERFACE_ENTRY(IConnectionPointContainer)
40        COM_INTERFACE_ENTRY(IProvideClassInfo2)
41        COM_INTERFACE_ENTRY(IProvideClassInfo)
42END_COM_MAP()
43
44BEGIN_CONNECTION_POINT_MAP(CFoo)
45        CONNECTION_POINT_ENTRY(__uuidof(_IFooEvents))
46END_CONNECTION_POINT_MAP()
47
48public:
49// CFoo
50        CFoo()
51        {
52                ATLTRACE(atlTraceRefcount, 4, _T("this 0x%p\n"), this);
53        }
54
55// IFoo
56        STDMETHOD(Method)(BSTR sText) throw()
57        {
58                ATLTRACE(atlTraceCOM, 4, _T("sText \"%s\"\n"), CString(sText));
59                ATLVERIFY(SUCCEEDED(Fire_Event(sText)));
60                return S_OK;
61        }
62};
63
64OBJECT_ENTRY_AUTO(__uuidof(Foo), CFoo)
Note: See TracBrowser for help on using the repository browser.