forked from rime/weasel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Compartment.h
30 lines (24 loc) · 781 Bytes
/
Compartment.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
#include <functional>
#include <msctf.h>
class CCompartmentEventSink : public ITfCompartmentEventSink {
public:
using Callback = std::function<HRESULT(REFGUID guidCompartment)>;
CCompartmentEventSink(Callback callback)
: _callback(callback), _refCount(1){};
~CCompartmentEventSink() = default;
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid, _Outptr_ void** ppvObj);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
// ITfCompartmentEventSink
STDMETHODIMP OnChange(_In_ REFGUID guid);
// function
HRESULT _Advise(_In_ com_ptr<IUnknown> punk, _In_ REFGUID guidCompartment);
HRESULT _Unadvise();
private:
com_ptr<ITfCompartment> _compartment;
DWORD _cookie;
Callback _callback;
LONG _refCount;
};