mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-05 04:39:08 +08:00
FIX : [Settings] - Can start multiple settings dialogs (#2421)
* Launch new wpf process with same/old ipc names * updated bring window to front * reverted change * removed unused string
This commit is contained in:
parent
36559d0264
commit
d65e2ab2d4
@ -350,15 +350,27 @@ LExit:
|
|||||||
g_settings_process_id = 0;
|
g_settings_process_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MAX_TITLE_LENGTH 100
|
||||||
void bring_settings_to_front()
|
void bring_settings_to_front()
|
||||||
{
|
{
|
||||||
auto callback = [](HWND hwnd, LPARAM data) -> BOOL {
|
auto callback = [](HWND hwnd, LPARAM data) -> BOOL {
|
||||||
DWORD processId;
|
DWORD processId;
|
||||||
if (GetWindowThreadProcessId(hwnd, &processId) && processId == g_settings_process_id)
|
if (GetWindowThreadProcessId(hwnd, &processId) && processId == g_settings_process_id)
|
||||||
{
|
{
|
||||||
ShowWindow(hwnd, SW_NORMAL);
|
std::wstring windowTitle = L"PowerToys Settings";
|
||||||
SetForegroundWindow(hwnd);
|
|
||||||
return FALSE;
|
WCHAR title[MAX_TITLE_LENGTH];
|
||||||
|
int len = GetWindowTextW(hwnd, title, MAX_TITLE_LENGTH);
|
||||||
|
if (len <= 0)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if (wcsncmp(title, windowTitle.c_str(), len) == 0)
|
||||||
|
{
|
||||||
|
ShowWindow(hwnd, SW_RESTORE);
|
||||||
|
SetForegroundWindow(hwnd);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
Loading…
Reference in New Issue
Block a user