Guest User

Untitled

a guest
Dec 13th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <Windows.h>
  2.  
  3. using namespace Windows::ApplicationModel::Activation;
  4. using namespace Windows::Foundation;
  5. using namespace Windows::UI::Core;
  6. using namespace Windows::UI::Xaml;
  7. using namespace Windows::UI::Xaml::Controls;
  8.  
  9. ref struct MainPage sealed : Page
  10. {
  11. MainPage()
  12. {
  13. OutputDebugStringA("MainPage\n");
  14. }
  15.  
  16. private:
  17.  
  18. ~MainPage()
  19. {
  20. OutputDebugStringA("~MainPage\n");
  21. }
  22. };
  23.  
  24. ref struct App sealed : Application
  25. {
  26. void OnLaunched(LaunchActivatedEventArgs^) override
  27. {
  28. Window^ window = Window::Current;
  29.  
  30. window->Content = ref new MainPage; // MainPage is called.
  31.  
  32. window->CoreWindow->PointerPressed += ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>([](auto&&...)
  33. {
  34. Window::Current->Content = nullptr; // ~MainPage is NOT called.
  35. });
  36.  
  37. window->Activate();
  38. }
  39. };
  40.  
  41. int main(Platform::Array<Platform::String^>^ args)
  42. {
  43. Application::Start(ref new ApplicationInitializationCallback([](auto &&) { ref new App; }));
  44. }
Add Comment
Please, Sign In to add comment