This repository was archived by the owner on Jun 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cpp
More file actions
57 lines (52 loc) · 2.12 KB
/
Copy pathApp.xaml.cpp
File metadata and controls
57 lines (52 loc) · 2.12 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
48
49
50
51
52
53
54
55
56
57
#include "pch.h"
#include "App.xaml.h"
#include "MainWindow.xaml.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::Aegis::implementation
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
App::App()
{
// Xaml objects should not call InitializeComponent during construction.
// See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
UnhandledException([](IInspectable const&, UnhandledExceptionEventArgs const& e)
{
auto errorMessage = e.Message();
MessageBoxW(nullptr, errorMessage.c_str(), L"Aegis Unhandled Exception", MB_OK | MB_ICONERROR);
if (IsDebuggerPresent())
{
__debugbreak();
}
});
}
/// <summary>
/// Invoked when the application is launched.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
void App::OnLaunched([[maybe_unused]] LaunchActivatedEventArgs const& e)
{
try {
window = make<MainWindow>();
window.Activate();
}
catch (winrt::hresult_error const& ex) {
MessageBoxW(nullptr, (L"HRESULT Error: " + std::wstring(ex.message())).c_str(), L"Activation Error", MB_OK | MB_ICONERROR);
}
catch (std::runtime_error const& ex) {
std::string msg = ex.what();
std::wstring wmsg(msg.begin(), msg.end());
MessageBoxW(nullptr, (L"Runtime Error: " + wmsg).c_str(), L"Activation Error", MB_OK | MB_ICONERROR);
}
catch (std::exception const& ex) {
std::string msg = ex.what();
std::wstring wmsg(msg.begin(), msg.end());
MessageBoxW(nullptr, (L"Standard Exception: " + wmsg).c_str(), L"Activation Error", MB_OK | MB_ICONERROR);
}
}
}