-
Notifications
You must be signed in to change notification settings - Fork 216
/
Main.cpp
49 lines (39 loc) · 1.75 KB
/
Main.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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "CompositionWindow.h"
#include "WebView2Window.h"
#include "Utilities.h"
namespace winrt
{
using namespace Windows::UI::Composition;
}
int __stdcall WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PSTR, _In_ int)
{
winrt::init_apartment(winrt::apartment_type::single_threaded);
// Enable referencing the WindowsAppSDK from an unpackaged app.
// Remember to have a matching Microsoft.WindowsAppRuntime.Redist installed.
// https://docs.microsoft.com/en-us/windows/apps/windows-app-sdk/deploy-unpackaged-apps
// There are two options to initialize the bootstrapper, use the utility function here
// Utilities::WindowsAppSDKBootstrapperContext sdkContext;
// or add the following tags to your .vcx project file, as done in this sample:
// <WindowsPackageType>None</WindowsPackageType>
// <LogSDKReferenceResolutionErrorsAsWarnings>true< / LogSDKReferenceResolutionErrorsAsWarnings>
//
// Register Window Class before making the window
CompositionWindow::RegisterWindowClass();
// Mica requires a compositor, which also requires a dispatcher queue
auto controller = Utilities::CreateDispatcherQueueControllerForCurrentThread();
auto compositor = winrt::Compositor();
// Mica windows is inherited from the Mica Window class, which is an extension of the DesktopWindow Class
// Here we initialize the main window and set the title
auto window = WebView2Window(compositor, L"Hello, WebView2!");
// Message pump.
MSG msg;
while (GetMessageW(&msg, nullptr, 0, 0))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
return static_cast<int>(msg.wParam);
}