Opening settings when user is opening already running Powertoys (#1957)

* Added code to open general settings when opening second instance of powertoys
This commit is contained in:
Yevhenii Holovachov 2020-04-07 13:17:18 +03:00 committed by GitHub
parent f5ed9f1c33
commit de42d9f310
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,12 +149,11 @@ void github_update_checking_worker()
state.save();
}
}
void alert_already_running()
void open_menu_from_another_instance()
{
MessageBoxW(nullptr,
GET_RESOURCE_STRING(IDS_ANOTHER_INSTANCE_RUNNING).c_str(),
GET_RESOURCE_STRING(IDS_POWERTOYS).c_str(),
MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND);
HWND hwnd_main = FindWindow(L"PToyTrayIconWindow", NULL);
PostMessage(hwnd_main, WM_COMMAND, ID_SETTINGS_MENU_COMMAND, NULL);
}
int runner(bool isProcessElevated)
@ -320,7 +319,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
if (!msix_mutex)
{
// The MSIX version is already running.
alert_already_running();
open_menu_from_another_instance();
return 0;
}
@ -337,7 +336,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
msi_mutex = create_msi_mutex();
if (!msi_mutex)
{
alert_already_running();
open_menu_from_another_instance();
return 0;
}
}
@ -355,7 +354,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
if (!msi_mutex)
{
// The MSI version is already running.
alert_already_running();
open_menu_from_another_instance();
return 0;
}
@ -366,7 +365,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
if (!msix_mutex)
{
// The MSIX version is already running.
alert_already_running();
open_menu_from_another_instance();
return 0;
}
else