From 3695ca3fac6dd0aeaee314805a17c9de47d6e4b1 Mon Sep 17 00:00:00 2001 From: "Michael A. Hawker" Date: Sat, 6 Nov 2021 17:02:00 -0700 Subject: [PATCH] Add listening to Escape and 'Q' keys to close Win32 sample window --- .../Backend/Win32ApplicationRunner.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs index 9cdfe230..8d0a0c30 100644 --- a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs +++ b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs @@ -148,6 +148,12 @@ internal unsafe static class Win32ApplicationRunner { Thread.Sleep(100); } + + // Also listen to Escape and 'Q' to Quit. + if (msg.message == Windows.WM_KEYUP && (msg.wParam == Windows.VK_ESCAPE || msg.wParam == 0x51)) + { + _ = Windows.DestroyWindow(hwnd); + } } tokenSource.Cancel();