-
Notifications
You must be signed in to change notification settings - Fork 432
Expand file tree
/
Copy pathGraphicsCaptureItem.cpp
More file actions
47 lines (42 loc) · 1.84 KB
/
GraphicsCaptureItem.cpp
File metadata and controls
47 lines (42 loc) · 1.84 KB
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
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "GraphicsCaptureItem.h"
#include "Microsoft.Windows.Graphics.Capture.GraphicsCaptureItem.g.cpp"
#include <winrt/Windows.Graphics.Capture.h>
#include <windows.graphics.capture.interop.h>
namespace winrt::Microsoft::Windows::Graphics::Capture::implementation
{
winrt::Windows::Graphics::Capture::GraphicsCaptureItem GraphicsCaptureItem::TryCreateFromWindowId(
winrt::Microsoft::UI::WindowId const& windowId)
{
auto hwnd{ reinterpret_cast<HWND>(windowId.Value) };
if (!hwnd)
{
return nullptr;
}
auto factory{ winrt::get_activation_factory<winrt::Windows::Graphics::Capture::GraphicsCaptureItem, IGraphicsCaptureItemInterop>() };
winrt::Windows::Graphics::Capture::GraphicsCaptureItem item{ nullptr };
if (FAILED(factory->CreateForWindow(hwnd, winrt::guid_of<winrt::Windows::Graphics::Capture::GraphicsCaptureItem>(), winrt::put_abi(item))))
{
return nullptr;
}
return item;
}
winrt::Windows::Graphics::Capture::GraphicsCaptureItem GraphicsCaptureItem::TryCreateFromDisplayId(
winrt::Microsoft::UI::DisplayId const& displayId)
{
auto hmonitor{ reinterpret_cast<HMONITOR>(displayId.Value) };
if (!hmonitor)
{
return nullptr;
}
auto factory{ winrt::get_activation_factory<winrt::Windows::Graphics::Capture::GraphicsCaptureItem, IGraphicsCaptureItemInterop>() };
winrt::Windows::Graphics::Capture::GraphicsCaptureItem item{ nullptr };
if (FAILED(factory->CreateForMonitor(hmonitor, winrt::guid_of<winrt::Windows::Graphics::Capture::GraphicsCaptureItem>(), winrt::put_abi(item))))
{
return nullptr;
}
return item;
}
}