forked from microsoft/CsWinRT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComImports.cpp
63 lines (52 loc) · 1.44 KB
/
ComImports.cpp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "pch.h"
#include "Class.h"
#include "ComImports.h"
#include "ComImports.g.cpp"
using namespace winrt;
using namespace Windows::Foundation;
namespace WF = Windows::Foundation;
namespace winrt::TestComponentCSharp::implementation
{
namespace statics
{
int _count{};
}
struct __declspec(uuid("EECDBF0E-BAE9-4CB6-A68E-9598E1CB57BB")) IWindowNative : ::IUnknown
{
virtual HRESULT __stdcall get_WindowHandle(HWND* hWnd) noexcept = 0;
};
struct __declspec(uuid("3E68D4BD-7135-4D10-8018-9FB6D9F33FA1")) IInitializeWithWindow : ::IUnknown
{
virtual HRESULT __stdcall Initialize(HWND hWnd) noexcept = 0;
};
struct ComImportObject : winrt::implements<ComImportObject, WF::IInspectable, IWindowNative, IInitializeWithWindow>
{
ComImportObject()
{
++statics::_count;
}
~ComImportObject()
{
--statics::_count;
}
HWND m_hWnd = (HWND)0;
HRESULT __stdcall get_WindowHandle(HWND* hWnd) noexcept override
{
*hWnd = m_hWnd;
return 0;
}
HRESULT __stdcall Initialize(HWND hWnd) noexcept override
{
m_hWnd = hWnd;
return 0;
}
};
WF::IInspectable ComImports::MakeObject()
{
return winrt::make<ComImportObject>();
}
int32_t ComImports::NumObjects()
{
return statics::_count;
}
}