mirror of
https://github.com/Open-Shell/Open-Shell-Menu.git
synced 2026-04-20 02:34:41 +10:00
Update: Properly handle toast activation
Use `OnToastActivate` to display update dialog if user clicked on toast during `update.exe` life-time. Process messages for some time after displaying toast. Otherwise toast may be not displayed at all.
This commit is contained in:
@@ -422,6 +422,9 @@ void CUpdateDlg::UpdateUI( void )
|
|||||||
|
|
||||||
void CUpdateDlg::Run( void )
|
void CUpdateDlg::Run( void )
|
||||||
{
|
{
|
||||||
|
if (m_hWnd)
|
||||||
|
return;
|
||||||
|
|
||||||
DLGTEMPLATE *pTemplate=LoadDialogEx(IDD_UPDATE);
|
DLGTEMPLATE *pTemplate=LoadDialogEx(IDD_UPDATE);
|
||||||
Create(NULL,pTemplate);
|
Create(NULL,pTemplate);
|
||||||
MSG msg;
|
MSG msg;
|
||||||
@@ -480,6 +483,20 @@ protected:
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class UpdateToasts : public DesktopToasts
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UpdateToasts() : DesktopToasts(L"OpenShell.Update") {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void OnToastActivate(LPCWSTR invokedArgs) override
|
||||||
|
{
|
||||||
|
g_UpdateDlg.Run();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow )
|
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow )
|
||||||
{
|
{
|
||||||
INITCOMMONCONTROLSEX init={sizeof(init),ICC_STANDARD_CLASSES};
|
INITCOMMONCONTROLSEX init={sizeof(init),ICC_STANDARD_CLASSES};
|
||||||
@@ -522,7 +539,7 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrC
|
|||||||
COwnerWindow ownerWindow;
|
COwnerWindow ownerWindow;
|
||||||
ownerWindow.Create(NULL,0,0,WS_POPUP);
|
ownerWindow.Create(NULL,0,0,WS_POPUP);
|
||||||
|
|
||||||
DesktopToasts toasts(L"OpenShell.Update");
|
UpdateToasts toasts;
|
||||||
|
|
||||||
if (wcsstr(lpstrCmdLine,L"-popup")!=NULL)
|
if (wcsstr(lpstrCmdLine,L"-popup")!=NULL)
|
||||||
{
|
{
|
||||||
@@ -591,12 +608,25 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrC
|
|||||||
else if (wcsstr(lpstrCmdLine, L"-ToastActivated"))
|
else if (wcsstr(lpstrCmdLine, L"-ToastActivated"))
|
||||||
{
|
{
|
||||||
g_UpdateDlg.UpdateData();
|
g_UpdateDlg.UpdateData();
|
||||||
g_UpdateDlg.Run();
|
// dialog will be shown once toast is activated (UpdateToasts::OnToastActivate)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_UpdateDlg.Run();
|
g_UpdateDlg.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// process messages for a while
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
MSG msg;
|
||||||
|
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
||||||
|
{
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
Sleep(10);
|
||||||
|
}
|
||||||
|
|
||||||
ownerWindow.DestroyWindow();
|
ownerWindow.DestroyWindow();
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user