@@ -422,6 +422,9 @@ void CUpdateDlg::UpdateUI( void )
422
422
423
423
void CUpdateDlg::Run ( void )
424
424
{
425
+ if (m_hWnd)
426
+ return ;
427
+
425
428
DLGTEMPLATE *pTemplate=LoadDialogEx (IDD_UPDATE);
426
429
Create (NULL ,pTemplate);
427
430
MSG msg;
@@ -480,6 +483,20 @@ class COwnerWindow: public CWindowImpl<COwnerWindow>
480
483
481
484
// /////////////////////////////////////////////////////////////////////////////
482
485
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
+
483
500
int WINAPI wWinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow )
484
501
{
485
502
INITCOMMONCONTROLSEX init={sizeof (init),ICC_STANDARD_CLASSES};
@@ -522,7 +539,7 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrC
522
539
COwnerWindow ownerWindow;
523
540
ownerWindow.Create (NULL ,0 ,0 ,WS_POPUP);
524
541
525
- DesktopToasts toasts ( L" OpenShell.Update " ) ;
542
+ UpdateToasts toasts;
526
543
527
544
if (wcsstr (lpstrCmdLine,L" -popup" )!=NULL )
528
545
{
@@ -591,12 +608,25 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrC
591
608
else if (wcsstr (lpstrCmdLine, L" -ToastActivated" ))
592
609
{
593
610
g_UpdateDlg.UpdateData ();
594
- g_UpdateDlg. Run ();
611
+ // dialog will be shown once toast is activated (UpdateToasts::OnToastActivate)
595
612
}
596
613
else
597
614
{
598
615
g_UpdateDlg.Run ();
599
616
}
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
+
600
630
ownerWindow.DestroyWindow ();
601
631
CoUninitialize ();
602
632
return 0 ;
0 commit comments