16
16
#include " ResourceHelper.h"
17
17
#include " Translations.h"
18
18
#include < shlobj.h>
19
+ #include " DesktopToasts/DesktopToasts.h"
19
20
20
21
21
22
void ClosingSettings ( HWND hWnd, int flags, int command )
@@ -487,8 +488,6 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrC
487
488
CString language=GetSettingString (L" Language" );
488
489
ParseTranslations (NULL ,language);
489
490
490
- g_Instance=hInstance;
491
-
492
491
HINSTANCE resInstance=LoadTranslationDll (language);
493
492
494
493
LoadTranslationResources (resInstance,g_LoadDialogs);
@@ -500,60 +499,78 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrC
500
499
501
500
COwnerWindow ownerWindow;
502
501
ownerWindow.Create (NULL ,0 ,0 ,WS_POPUP);
502
+
503
+ DesktopToasts toasts (L" OpenShell.Update" );
504
+
503
505
if (wcsstr (lpstrCmdLine,L" -popup" )!=NULL )
504
506
{
505
507
g_UpdateDlg.UpdateData ();
506
508
// wait at least 5 seconds before showing the balloon
507
509
int sleep=5000 -(timeGetTime ()-time0);
508
510
if (sleep>0 )
509
511
Sleep (sleep);
510
- HWND balloon=CreateWindowEx (WS_EX_TOPMOST|WS_EX_TOOLWINDOW|(IsLanguageRTL ()?WS_EX_LAYOUTRTL:0 ),TOOLTIPS_CLASS,NULL ,WS_POPUP|TTS_CLOSE|TTS_NOPREFIX,0 ,0 ,0 ,0 ,NULL ,NULL ,g_Instance,NULL );
511
- SendMessage (balloon,TTM_SETMAXTIPWIDTH,0 ,500 );
512
- TOOLINFO tool={sizeof (tool),TTF_ABSOLUTE|TTF_TRANSPARENT|TTF_TRACK|(IsLanguageRTL ()?TTF_RTLREADING:0U )};
513
- tool.uId =1 ;
514
- CString message=LoadStringEx (g_UpdateDlg.HasNewLanguage ()?IDS_LANG_NEWVERSION:IDS_NEWVERSION);
515
- tool.lpszText =(wchar_t *)(const wchar_t *)message;
516
- SendMessage (balloon,TTM_ADDTOOL,0 ,(LPARAM)&tool);
517
- SendMessage (balloon,TTM_SETTITLE,(WPARAM)LoadIcon (g_Instance,MAKEINTRESOURCE (IDI_APPICON)),(LPARAM)(const wchar_t *)LoadStringEx (IDS_UPDATE_TITLE));
518
- APPBARDATA appbar={sizeof (appbar)};
519
- SHAppBarMessage (ABM_GETTASKBARPOS,&appbar);
520
- MONITORINFO info={sizeof (info)};
521
- GetMonitorInfo (MonitorFromWindow (appbar.hWnd ,MONITOR_DEFAULTTOPRIMARY),&info);
522
- SendMessage (balloon,TTM_TRACKPOSITION,0 ,0 );
523
- SendMessage (balloon,TTM_TRACKACTIVATE,TRUE ,(LPARAM)&tool);
524
- RECT rc;
525
- GetWindowRect (balloon,&rc);
526
- LONG pos;
527
- if (appbar.uEdge ==ABE_LEFT)
528
- pos=MAKELONG (info.rcWork .left ,info.rcWork .bottom -rc.bottom +rc.top );
529
- else if (appbar.uEdge ==ABE_RIGHT)
530
- pos=MAKELONG (info.rcWork .right -rc.right +rc.left ,info.rcWork .bottom -rc.bottom +rc.top );
531
- else if (appbar.uEdge ==ABE_TOP)
532
- pos=MAKELONG (IsLanguageRTL ()?info.rcWork .left :info.rcWork .right -rc.right +rc.left ,info.rcWork .top );
512
+
513
+ auto title = LoadStringEx (IDS_UPDATE_TITLE);
514
+ auto message = LoadStringEx (g_UpdateDlg.HasNewLanguage () ? IDS_LANG_NEWVERSION : IDS_NEWVERSION);
515
+
516
+ if (toasts)
517
+ {
518
+ toasts.DisplaySimpleToast (title, message);
519
+ }
533
520
else
534
- pos=MAKELONG (IsLanguageRTL ()?info.rcWork .left :info.rcWork .right -rc.right +rc.left ,info.rcWork .bottom -rc.bottom +rc.top );
535
- SendMessage (balloon,TTM_TRACKPOSITION,0 ,pos);
536
- SetWindowSubclass (balloon,SubclassBalloonProc,0 ,' CLSH' );
537
- PlaySound (L" SystemNotification" ,NULL ,SND_APPLICATION|SND_ALIAS|SND_ASYNC|SND_NODEFAULT|SND_SYSTEM);
538
- int time0=timeGetTime ();
539
- while (IsWindowVisible (balloon))
540
521
{
541
- if (time0 && (timeGetTime ()-time0)>=15000 )
542
- {
543
- time0=0 ;
544
- TOOLINFO tool={sizeof (tool)};
545
- tool.uId =1 ;
546
- SendMessage (balloon,TTM_TRACKACTIVATE,FALSE ,(LPARAM)&tool);
547
- }
548
- MSG msg;
549
- while (PeekMessage (&msg,0 ,0 ,0 ,PM_REMOVE))
522
+ HWND balloon = CreateWindowEx (WS_EX_TOPMOST | WS_EX_TOOLWINDOW | (IsLanguageRTL () ? WS_EX_LAYOUTRTL : 0 ), TOOLTIPS_CLASS, NULL , WS_POPUP | TTS_CLOSE | TTS_NOPREFIX, 0 , 0 , 0 , 0 , NULL , NULL , g_Instance, NULL );
523
+ SendMessage (balloon, TTM_SETMAXTIPWIDTH, 0 , 500 );
524
+ TOOLINFO tool = { sizeof (tool),TTF_ABSOLUTE | TTF_TRANSPARENT | TTF_TRACK | (IsLanguageRTL () ? TTF_RTLREADING : 0U ) };
525
+ tool.uId = 1 ;
526
+ tool.lpszText = (wchar_t *)(const wchar_t *)message;
527
+ SendMessage (balloon, TTM_ADDTOOL, 0 , (LPARAM)&tool);
528
+ SendMessage (balloon, TTM_SETTITLE, (WPARAM)LoadIcon (g_Instance, MAKEINTRESOURCE (IDI_APPICON)), (LPARAM)(const wchar_t *)title);
529
+ APPBARDATA appbar = { sizeof (appbar) };
530
+ SHAppBarMessage (ABM_GETTASKBARPOS, &appbar);
531
+ MONITORINFO info = { sizeof (info) };
532
+ GetMonitorInfo (MonitorFromWindow (appbar.hWnd , MONITOR_DEFAULTTOPRIMARY), &info);
533
+ SendMessage (balloon, TTM_TRACKPOSITION, 0 , 0 );
534
+ SendMessage (balloon, TTM_TRACKACTIVATE, TRUE , (LPARAM)&tool);
535
+ RECT rc;
536
+ GetWindowRect (balloon, &rc);
537
+ LONG pos;
538
+ if (appbar.uEdge == ABE_LEFT)
539
+ pos = MAKELONG (info.rcWork .left , info.rcWork .bottom - rc.bottom + rc.top );
540
+ else if (appbar.uEdge == ABE_RIGHT)
541
+ pos = MAKELONG (info.rcWork .right - rc.right + rc.left , info.rcWork .bottom - rc.bottom + rc.top );
542
+ else if (appbar.uEdge == ABE_TOP)
543
+ pos = MAKELONG (IsLanguageRTL () ? info.rcWork .left : info.rcWork .right - rc.right + rc.left , info.rcWork .top );
544
+ else
545
+ pos = MAKELONG (IsLanguageRTL () ? info.rcWork .left : info.rcWork .right - rc.right + rc.left , info.rcWork .bottom - rc.bottom + rc.top );
546
+ SendMessage (balloon, TTM_TRACKPOSITION, 0 , pos);
547
+ SetWindowSubclass (balloon, SubclassBalloonProc, 0 , ' CLSH' );
548
+ PlaySound (L" SystemNotification" , NULL , SND_APPLICATION | SND_ALIAS | SND_ASYNC | SND_NODEFAULT | SND_SYSTEM);
549
+ int time0 = timeGetTime ();
550
+ while (IsWindowVisible (balloon))
550
551
{
551
- TranslateMessage (&msg);
552
- DispatchMessage (&msg);
552
+ if (time0 && (timeGetTime () - time0) >= 15000 )
553
+ {
554
+ time0 = 0 ;
555
+ TOOLINFO tool = { sizeof (tool) };
556
+ tool.uId = 1 ;
557
+ SendMessage (balloon, TTM_TRACKACTIVATE, FALSE , (LPARAM)&tool);
558
+ }
559
+ MSG msg;
560
+ while (PeekMessage (&msg, 0 , 0 , 0 , PM_REMOVE))
561
+ {
562
+ TranslateMessage (&msg);
563
+ DispatchMessage (&msg);
564
+ }
565
+ Sleep (10 );
553
566
}
554
- Sleep (10 );
555
567
}
556
568
}
569
+ else if (wcsstr (lpstrCmdLine, L" -ToastActivated" ))
570
+ {
571
+ g_UpdateDlg.UpdateData ();
572
+ g_UpdateDlg.Run ();
573
+ }
557
574
else
558
575
{
559
576
g_UpdateDlg.Run ();
0 commit comments