Skip to content

Instantly share code, notes, and snippets.

@kennykerr
Last active September 30, 2020 13:19
Show Gist options
  • Save kennykerr/24954773154f9d3e7e853e7d4f5bc823 to your computer and use it in GitHub Desktop.
Save kennykerr/24954773154f9d3e7e853e7d4f5bc823 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include "winrt/Windows.ApplicationModel.Core.h"
#include "winrt/Windows.UI.Core.h"
using namespace winrt;
using namespace Windows::ApplicationModel::Core;
using namespace Windows::UI::Core;
struct App : implements<App, IFrameworkViewSource, IFrameworkView>
{
IFrameworkView CreateView()
{
return *this;
}
void Initialize(CoreApplicationView const&)
{
}
void Load(hstring const&)
{
}
void Uninitialize()
{
}
void Run()
{
CoreWindow window = CoreWindow::GetForCurrentThread();
window.Activate();
CoreDispatcher dispatcher = window.Dispatcher();
dispatcher.ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit);
}
void SetWindow(CoreWindow const& window)
{
window.PointerPressed([&](auto&&...)
{
throw hresult_invalid_argument(L"Don't touch me!");
});
}
};
int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
{
CoreApplication::UnhandledErrorDetected([](auto&&, auto&& args)
{
if (!args.UnhandledError().Handled())
{
try
{
args.UnhandledError().Propagate();
}
catch (hresult_error const& e)
{
auto message = e.message();
OutputDebugString(message.c_str());
}
}
});
CoreApplication::Run(make<App>());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment