-
Notifications
You must be signed in to change notification settings - Fork 405
Open
Labels
Description
Describe the bug
When clicking a notification that a MSIX-packaged app creates, it opens a second instance instead of behaving like unpackaged apps and bringing the app window in the foreground.
Steps to reproduce the bug
- Create a new C++ WinUI 3 app
- Add the following to
MainWindow.xaml.h:void InitializeComponent(); void Button_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e); private: NOTIFYICONDATA m_icon;
- Add the following to
MainWindow.xaml:<Grid> <Button Click="Button_Click">Send notification</Button> </Grid>
- Add the following to
MainWindow.xaml.cpp:void winrt::App4::implementation::MainWindow::InitializeComponent() { MainWindowT::InitializeComponent(); HWND window{}; winrt::check_hresult(m_inner.as<IWindowNative>()->get_WindowHandle(&window)); m_icon = { .cbSize = sizeof(m_icon), .hWnd = window, .uID = 45678908, .uFlags = NIF_MESSAGE | NIF_TIP | NIF_SHOWTIP | NIF_ICON, .uCallbackMessage = 0xbeef, .hIcon = ExtractIcon(nullptr, L"shell32.dll", 130), .szTip = L"test_app", .uVersion = NOTIFYICON_VERSION_4 }; Shell_NotifyIcon(NIM_ADD, &m_icon); Shell_NotifyIcon(NIM_SETVERSION, &m_icon); } void winrt::App4::implementation::MainWindow::Button_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e) { auto icon = m_icon; icon.uFlags |= NIF_INFO; icon.dwInfoFlags = NIIF_INFO; wcscpy_s(icon.szInfo, L"test_app"); wcscpy_s(icon.szInfoTitle, L"test_app"); BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon); }
- Edit the project file for unpackaged and launch the app unpackaged
- Click button and click notification. Observe no second instance is created.
- Edit the project file for packaged and launch the app pckaged.
- Click button and click notification. Observe a second instance of the app is created.
Expected behavior
No second instance is created, even when the app is packaged. This was the behavior previously as well
Screenshots
No response
NuGet package version
Windows App SDK 1.8.3: 1.8.251106002
Packaging type
Packaged (MSIX)
Windows version
Insider Build (xxxxx)
IDE
Visual Studio 2022
Additional context
Windows 11 26200.7296
Full repro project here:
https://github.com/sylveon/ShellNotifyIcon-packaged