@@ -422,6 +422,9 @@ void CUpdateDlg::UpdateUI( void )
422422
423423void CUpdateDlg::Run ( void )
424424{
425+ if (m_hWnd)
426+ return ;
427+
425428 DLGTEMPLATE *pTemplate=LoadDialogEx (IDD_UPDATE);
426429 Create (NULL ,pTemplate);
427430 MSG msg;
@@ -480,6 +483,20 @@ class COwnerWindow: public CWindowImpl<COwnerWindow>
480483
481484// /////////////////////////////////////////////////////////////////////////////
482485
486+ class UpdateToasts : public DesktopToasts
487+ {
488+ public:
489+ UpdateToasts () : DesktopToasts(L" OpenShell.Update" ) {}
490+
491+ private:
492+ void OnToastActivate (LPCWSTR invokedArgs) override
493+ {
494+ g_UpdateDlg.Run ();
495+ }
496+ };
497+
498+ // /////////////////////////////////////////////////////////////////////////////
499+
483500int WINAPI wWinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow )
484501{
485502 INITCOMMONCONTROLSEX init={sizeof (init),ICC_STANDARD_CLASSES};
@@ -522,7 +539,7 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrC
522539 COwnerWindow ownerWindow;
523540 ownerWindow.Create (NULL ,0 ,0 ,WS_POPUP);
524541
525- DesktopToasts toasts ( L" OpenShell.Update " ) ;
542+ UpdateToasts toasts;
526543
527544 if (wcsstr (lpstrCmdLine,L" -popup" )!=NULL )
528545 {
@@ -591,12 +608,25 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrC
591608 else if (wcsstr (lpstrCmdLine, L" -ToastActivated" ))
592609 {
593610 g_UpdateDlg.UpdateData ();
594- g_UpdateDlg. Run ();
611+ // dialog will be shown once toast is activated (UpdateToasts::OnToastActivate)
595612 }
596613 else
597614 {
598615 g_UpdateDlg.Run ();
599616 }
617+
618+ // process messages for a while
619+ for (int i = 0 ; i < 100 ; i++)
620+ {
621+ MSG msg;
622+ while (PeekMessage (&msg, 0 , 0 , 0 , PM_REMOVE))
623+ {
624+ TranslateMessage (&msg);
625+ DispatchMessage (&msg);
626+ }
627+ Sleep (10 );
628+ }
629+
600630 ownerWindow.DestroyWindow ();
601631 CoUninitialize ();
602632 return 0 ;
0 commit comments