mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-04 11:59:07 +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;
|
||||
}
|
||||
|
||||
#define MAX_TITLE_LENGTH 100
|
||||
void bring_settings_to_front()
|
||||
{
|
||||
auto callback = [](HWND hwnd, LPARAM data) -> BOOL {
|
||||
DWORD processId;
|
||||
if (GetWindowThreadProcessId(hwnd, &processId) && processId == g_settings_process_id)
|
||||
{
|
||||
ShowWindow(hwnd, SW_NORMAL);
|
||||
SetForegroundWindow(hwnd);
|
||||
return FALSE;
|
||||
std::wstring windowTitle = L"PowerToys Settings";
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user