@@ -21,25 +21,30 @@ int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
21
21
auto controller{ winrt::DispatcherQueueController::CreateOnCurrentThread () };
22
22
auto queue = controller.DispatcherQueue ();
23
23
24
+ auto compositor = winrt::Compositor ();
25
+ auto island = winrt::DrawingIsland (compositor).Island ();
26
+
27
+ // Associating the AppWindow with the DispatcherQueue on which the ContentIsland is created
28
+ // will ensure that the ContentIsland is Closed when the AppWindow closes.
24
29
auto window = winrt::AppWindow::Create ();
25
30
window.AssociateWithDispatcherQueue (queue);
26
- window.Closing ([&](auto &&, auto &&)
31
+ window.Closing (
32
+ [queue](auto &&, auto &&)
27
33
{
34
+ // Ensure the DispatcherQueue exits the event loop on close.
28
35
queue.EnqueueEventLoopExit ();
29
36
});
30
37
31
38
window.Title (L" Drawing C++ TestApp" );
32
39
window.Show ();
33
40
34
- auto compositor = winrt::Compositor ();
35
- auto drawing = winrt::DrawingIsland (compositor);
36
-
41
+ // Create a ContentSiteBridge and connect the ContentIsland to it.
37
42
auto siteBridge = winrt::DesktopChildSiteBridge::Create (compositor, window.Id ());
38
43
siteBridge.ResizePolicy (winrt::ContentSizePolicy::ResizeContentToParentWindow);
39
44
siteBridge.Show ();
40
- siteBridge.Connect (drawing. Island () );
45
+ siteBridge.Connect (island );
41
46
42
- // Move initial focus to the island .
47
+ // Move initial focus to the ContentIsland .
43
48
auto focusNavigationHost = winrt::InputFocusNavigationHost::GetForSiteBridge (siteBridge);
44
49
focusNavigationHost.NavigateFocus (winrt::FocusNavigationRequest::Create (
45
50
winrt::FocusNavigationReason::Programmatic));
0 commit comments