-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cpp
63 lines (50 loc) · 1.89 KB
/
MainWindow.xaml.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
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "MainWindow.xaml.h"
#if __has_include("MainWindow.g.cpp")
#include "MainWindow.g.cpp"
#endif
// Only includes needed for added code in MainWindow:MainWindow()
#include <winrt/Microsoft.UI.Interop.h>
#include <Microsoft.UI.Xaml.Window.h>
#include <winrt/Microsoft.UI.Windowing.h>
using namespace winrt;
using namespace Microsoft::UI::Xaml;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace winrt::App1::implementation
{
MainWindow::MainWindow()
{
InitializeComponent();
// Get handle.
auto windowNative{ this->try_as<::IWindowNative>() };
winrt::check_bool(windowNative);
HWND hWnd{ 0 };
windowNative->get_WindowHandle(&hWnd);
// Retrieve the WindowId that corresponds to hWnd.
Microsoft::UI::WindowId windowId = Microsoft::UI::GetWindowIdFromWindow(hWnd);
// Retrieve the AppWindow for the current (XAML) WinUI 3 window.
Microsoft::UI::Windowing::AppWindow appWindow = Microsoft::UI::Windowing::AppWindow::GetFromWindowId(windowId);
// Titlebar full customization.
this->ExtendsContentIntoTitleBar(true);
this->SetTitleBar(AppTitleBar());
// Set drag rectangle.
/* winrt::Windows::Graphics::RectInt32 rect[]{(0,0,1,1)};
auto titlebar = appWindow.TitleBar();
titlebar.SetDragRectangles(rect);*/
}
int32_t MainWindow::MyProperty()
{
throw hresult_not_implemented();
}
void MainWindow::MyProperty(int32_t /* value */)
{
throw hresult_not_implemented();
}
//void MainWindow::myButton_Click(IInspectable const&, RoutedEventArgs const&)
//{
// /* myButton().Content(box_value(L"Clicked"));*/
//}
}