From c5a9bf1c331dab3e9a31abb1f9e5687fb280bf64 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Tue, 18 Aug 2015 18:46:06 +0000 Subject: Toaster: added MS_POPUP_QUERY service git-svn-id: http://svn.miranda-ng.org/main/trunk@14990 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Toaster/src/toast_notification.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'plugins/Toaster/src/toast_notification.cpp') diff --git a/plugins/Toaster/src/toast_notification.cpp b/plugins/Toaster/src/toast_notification.cpp index 856129f648..3430b404e0 100644 --- a/plugins/Toaster/src/toast_notification.cpp +++ b/plugins/Toaster/src/toast_notification.cpp @@ -3,10 +3,7 @@ ToastNotification::ToastNotification(_In_ wchar_t* text, _In_ wchar_t* caption, _In_ wchar_t* imagePath) throw() : _text(text), _caption(caption), _imagePath(imagePath) { - HRESULT hr = Windows::Foundation::GetActivationFactory(StringReferenceWrapper(RuntimeClass_Windows_UI_Notifications_ToastNotificationManager).Get(), &_notificationManager); - - if (FAILED(hr)) - RaiseException(static_cast(STATUS_INVALID_PARAMETER), EXCEPTION_NONCONTINUABLE, 0, nullptr); + } ToastNotification::~ToastNotification() @@ -157,10 +154,15 @@ HRESULT ToastNotification::Setup(_In_ ABI::Windows::Data::Xml::Dom::IXmlDocument HRESULT ToastNotification::CreateXml(_Outptr_ ABI::Windows::Data::Xml::Dom::IXmlDocument** xml) { + Microsoft::WRL::ComPtr notificationManager; + HRESULT hr = Windows::Foundation::GetActivationFactory(StringReferenceWrapper(RuntimeClass_Windows_UI_Notifications_ToastNotificationManager).Get(), ¬ificationManager); + if (FAILED(hr)) + RaiseException(static_cast(STATUS_INVALID_PARAMETER), EXCEPTION_NONCONTINUABLE, 0, nullptr); + ABI::Windows::UI::Notifications::ToastTemplateType templateId = _imagePath == nullptr ? ABI::Windows::UI::Notifications::ToastTemplateType_ToastText02 : ABI::Windows::UI::Notifications::ToastTemplateType_ToastImageAndText02; - HRESULT hr = _notificationManager->GetTemplateContent(templateId, xml); + hr = notificationManager->GetTemplateContent(templateId, xml); if (FAILED(hr)) return hr; @@ -208,8 +210,13 @@ HRESULT ToastNotification::Show() HRESULT ToastNotification::Show(_In_ ToastEventHandler* handler) { + Microsoft::WRL::ComPtr notificationManager; + HRESULT hr = Windows::Foundation::GetActivationFactory(StringReferenceWrapper(RuntimeClass_Windows_UI_Notifications_ToastNotificationManager).Get(), ¬ificationManager); + if (FAILED(hr)) + RaiseException(static_cast(STATUS_INVALID_PARAMETER), EXCEPTION_NONCONTINUABLE, 0, nullptr); + Microsoft::WRL::ComPtr notifier; - HRESULT hr = _notificationManager->CreateToastNotifierWithId(StringReferenceWrapper(::AppUserModelID).Get(), ¬ifier); + hr = notificationManager->CreateToastNotifierWithId(StringReferenceWrapper(::AppUserModelID).Get(), ¬ifier); if (FAILED(hr)) return hr; -- cgit v1.2.3