-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
WinMain.cpp
69 lines (56 loc) · 1.75 KB
/
WinMain.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
64
65
66
67
68
69
#include <Windows.h>
#include "pch.h"
#include "App.h"
#include "MainPage.h"
int WINAPI wWinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nShowCmd)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
winrt::init_apartment(winrt::apartment_type::single_threaded);
winrt::com_ptr<winrt::MileXamlBlankApp::implementation::App> app =
winrt::make_self<winrt::MileXamlBlankApp::implementation::App>();
winrt::MileXamlBlankApp::MainPage XamlWindowContent =
winrt::make<winrt::MileXamlBlankApp::implementation::MainPage>();
HWND WindowHandle = ::CreateWindowExW(
WS_EX_CLIENTEDGE,
L"Mile.Xaml.ContentWindow",
L"MileXamlBlankApp",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
nullptr,
nullptr,
hInstance,
winrt::get_abi(XamlWindowContent));
if (!WindowHandle)
{
return -1;
}
::ShowWindow(WindowHandle, nShowCmd);
::UpdateWindow(WindowHandle);
MSG Message;
while (::GetMessageW(&Message, nullptr, 0, 0))
{
// Workaround for capturing Alt+F4 in applications with XAML Islands.
// Reference: https://github.com/microsoft/microsoft-ui-xaml/issues/2408
if (Message.message == WM_SYSKEYDOWN && Message.wParam == VK_F4)
{
::SendMessageW(
::GetAncestor(Message.hwnd, GA_ROOT),
Message.message,
Message.wParam,
Message.lParam);
continue;
}
::TranslateMessage(&Message);
::DispatchMessageW(&Message);
}
app->Close();
return static_cast<int>(Message.wParam);
}