-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIslandWindow.cpp
More file actions
31 lines (23 loc) · 986 Bytes
/
IslandWindow.cpp
File metadata and controls
31 lines (23 loc) · 986 Bytes
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
#include "IslandWindow.h"
#include <windows.ui.xaml.interop.h>
winrt::Windows::UI::Xaml::Hosting::WindowsXamlManager IslandWindow::xamlManager{ nullptr };
IslandWindow::IslandWindow() : BaseWindow{L"UWPWindow"}
{
if(!xamlManager)
xamlManager = winrt::Windows::UI::Xaml::Hosting::WindowsXamlManager::InitializeForCurrentThread();
xamlSource = {};
interop = xamlSource.as<IDesktopWindowXamlSourceNative>();
winrt::check_hresult(interop->AttachToWindow(m_hwnd.get()));
winrt::check_hresult(interop->get_WindowHandle(&m_islandHwnd));
auto const clientRect = ClientRect();
SetWindowPos(m_islandHwnd, 0, 0, 0, clientRect.right, clientRect.bottom, SWP_SHOWWINDOW);
}
void IslandWindow::SetContent(winrt::Windows::UI::Xaml::UIElement const& content)
{
xamlSource.Content(content);
}
void IslandWindow::OnSize(HWND hwnd, WPARAM wparam, UINT width, UINT height)
{
auto self = getSelfFromHwnd(hwnd);
SetWindowPos(self->m_islandHwnd, 0, 0, 0, width, height, SWP_SHOWWINDOW);
}