mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 17:10:22 +00:00
parent
21b3382f31
commit
467dec4d16
2 changed files with 47 additions and 2 deletions
|
@ -25,6 +25,19 @@ public:
|
||||||
|
|
||||||
LRESULT OnInitDialog(UINT, WPARAM, LPARAM, BOOL&)
|
LRESULT OnInitDialog(UINT, WPARAM, LPARAM, BOOL&)
|
||||||
{
|
{
|
||||||
|
// Try to find an existing instance of this dialog
|
||||||
|
WCHAR buf[300];
|
||||||
|
GetWindowTextW(buf, _countof(buf));
|
||||||
|
for (HWND hNext = NULL, hFind; (hFind = ::FindWindowExW(NULL, hNext, NULL, buf)) != NULL; hNext = hFind)
|
||||||
|
{
|
||||||
|
if (hFind != *this && ::IsWindowVisible(hFind))
|
||||||
|
{
|
||||||
|
::SetForegroundWindow(hFind);
|
||||||
|
EndDialog(IDCANCEL);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CWindow cbo = GetDlgItem(IDC_DRIVES);
|
CWindow cbo = GetDlgItem(IDC_DRIVES);
|
||||||
WCHAR VolumeNameBuffer[MAX_PATH + 1];
|
WCHAR VolumeNameBuffer[MAX_PATH + 1];
|
||||||
CStringW Tmp;
|
CStringW Tmp;
|
||||||
|
|
|
@ -247,6 +247,22 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline UINT GetWindowProcessId(_In_ HWND hWnd)
|
||||||
|
{
|
||||||
|
DWORD pid;
|
||||||
|
return GetWindowThreadProcessId(hWnd, &pid) ? pid : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL CALLBACK EnumSingleInstanceCallback(_In_ HWND hWnd, _In_ LPARAM lParam)
|
||||||
|
{
|
||||||
|
if (::IsWindowVisible(hWnd) && (LPARAM)GetWindowProcessId(hWnd) == lParam)
|
||||||
|
{
|
||||||
|
::SetForegroundWindow(hWnd);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT Run(_In_ int nShowCmd) throw()
|
HRESULT Run(_In_ int nShowCmd) throw()
|
||||||
{
|
{
|
||||||
if (m_Drive == UNICODE_NULL)
|
if (m_Drive == UNICODE_NULL)
|
||||||
|
@ -257,6 +273,19 @@ public:
|
||||||
if (m_Drive == UNICODE_NULL)
|
if (m_Drive == UNICODE_NULL)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
|
CStringW Title;
|
||||||
|
Title.Format(IDS_PROPERTIES_MAIN_TITLE, m_Drive);
|
||||||
|
|
||||||
|
HWND hWndInstance = ::CreateWindowExW(WS_EX_TOOLWINDOW, WC_STATIC, Title, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
|
||||||
|
for (HWND hNext = NULL, hFind; (hFind = ::FindWindowExW(NULL, hNext, WC_STATIC, Title)) != NULL; hNext = hFind)
|
||||||
|
{
|
||||||
|
if (hFind != hWndInstance)
|
||||||
|
{
|
||||||
|
::EnumWindows(EnumSingleInstanceCallback, GetWindowProcessId(hFind));
|
||||||
|
return S_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CCleanupHandlerList Handlers;
|
CCleanupHandlerList Handlers;
|
||||||
CEmptyVolumeCacheCallBack CacheCallBack;
|
CEmptyVolumeCacheCallBack CacheCallBack;
|
||||||
|
|
||||||
|
@ -271,16 +300,19 @@ public:
|
||||||
psh.dwFlags = PSH_NOAPPLYNOW | PSH_USEICONID | PSH_NOCONTEXTHELP;
|
psh.dwFlags = PSH_NOAPPLYNOW | PSH_USEICONID | PSH_NOCONTEXTHELP;
|
||||||
psh.hInstance = _AtlBaseModule.GetResourceInstance();
|
psh.hInstance = _AtlBaseModule.GetResourceInstance();
|
||||||
psh.pszIcon = MAKEINTRESOURCEW(IDI_CLEANMGR);
|
psh.pszIcon = MAKEINTRESOURCEW(IDI_CLEANMGR);
|
||||||
CStringW Title;
|
|
||||||
Title.Format(IDS_PROPERTIES_MAIN_TITLE, m_Drive);
|
|
||||||
psh.pszCaption = Title;
|
psh.pszCaption = Title;
|
||||||
psh.nPages = _countof(hpsp);
|
psh.nPages = _countof(hpsp);
|
||||||
psh.phpage = hpsp;
|
psh.phpage = hpsp;
|
||||||
|
|
||||||
if (PropertySheetW(&psh) >= 1)
|
if (PropertySheetW(&psh) >= 1)
|
||||||
{
|
{
|
||||||
|
::DestroyWindow(hWndInstance); // Allow new "cleanmgr /D" without waiting for these handlers
|
||||||
Handlers.ExecuteCleanup(&CacheCallBack);
|
Handlers.ExecuteCleanup(&CacheCallBack);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
::DestroyWindow(hWndInstance);
|
||||||
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue