[EXPLORER] Implement "Undo Cascade/Tile" menu items (#4817)

Implement taskbar context menu items "Undo Cascade" and "Undo Tile".
Based on patch by KRosUser.

CORE-18383
This commit is contained in:
Tuur Martens 2022-11-03 13:48:18 +01:00 committed by GitHub
parent 9642031d2a
commit be970d8d31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 141 additions and 0 deletions

View file

@ -195,4 +195,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Лента със задачи и Старт меню"
IDS_RESTORE_ALL "&Покажи отворените прозорци"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -201,4 +201,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Vlastnosti hlavního panelu a Start menu"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -195,4 +195,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Taskleisten- und Startmenüeinstellungen"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -195,4 +195,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Taskbar and Start Menu"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -207,4 +207,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Propiedades de la Barra de tareas y del Menú Inicio"
IDS_RESTORE_ALL "&Mostrar ventanas abiertas"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -202,4 +202,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Tegumiriba ja Menüü Start"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -202,4 +202,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Ataza-barra eta Hasi menuaren propietateak"
IDS_RESTORE_ALL "E&rakutsi irekitako leihoak"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -195,4 +195,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Tehtäväpalkki ja Käynnistä Valikko"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -195,4 +195,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Barre des tâches et Menu Démarrer"
IDS_RESTORE_ALL "&Afficher les fenêtres ouvertes"
IDS_TRAYWND_UNDO_CASCADE "Ann&uler cascade"
IDS_TRAYWND_UNDO_TILE "Ann&uler mosaïque"
END

View file

@ -195,4 +195,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "שורת המשימות ושולחן העבודה"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -195,4 +195,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "टास्कबार और स्टार्ट मेनू"
IDS_RESTORE_ALL "खुले हुऐ विंडोज &दिखाएं"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -195,4 +195,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Tálca és Start menü"
IDS_RESTORE_ALL "&Megnyitott ablakok megjelenítése"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -195,4 +195,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Bilah Tugas dan Menu Mulai"
IDS_RESTORE_ALL "&Tampilkan Semua Jendela"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -195,4 +195,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Proprietà della Barra delle applicazioni e del Menú di avvio"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -195,4 +195,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "タスクバーとスタートメニュー"
IDS_RESTORE_ALL "開いているウィンドウを表示(&S)"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -203,4 +203,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "작업 표시줄 및 시작 메뉴"
IDS_RESTORE_ALL "열린 창 보기(&S)"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -198,4 +198,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Taskbar and Start Menu"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -197,4 +197,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Bar Tugas dan Menu Mula"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -195,4 +195,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Taakbalk en menu Start eigenschappen"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -196,4 +196,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Egenskaper for oppgavelinjen og startmeny"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -206,4 +206,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Paska zadań i menu Start"
IDS_RESTORE_ALL "&Pokaż otwarte okna"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -197,4 +197,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Propriedades do Barra de Tarefas e Menu Iniciar"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -197,4 +197,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Barra de Tarefas e Menu Iniciar"
IDS_RESTORE_ALL "&Mostrar janelas abertas"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -197,4 +197,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Bara de activități și meniul „Pornire”"
IDS_RESTORE_ALL "&Afișează ferestrele deschise"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -197,4 +197,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Меню ""Пуск"" и панель задач"
IDS_RESTORE_ALL "&Показать окна"
IDS_TRAYWND_UNDO_CASCADE "&Отменить Каскадом"
IDS_TRAYWND_UNDO_TILE "&Отменить Окна рядом"
END

View file

@ -200,4 +200,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Vlastnosti panela úloh a ponuky Štart"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -199,4 +199,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Taskbar dhe Start Menu"
IDS_RESTORE_ALL "&Show Open Windows"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -200,4 +200,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Görev Çubuğu ve Başlat Menüsü"
IDS_RESTORE_ALL "&Açık Pencereleri Göster"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -203,4 +203,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "Властивості меню Пуск та Панелі завдань"
IDS_RESTORE_ALL "&Показати відкриті вікна"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -204,4 +204,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "任务栏和开始菜单属性"
IDS_RESTORE_ALL "显示打开的窗口(&S)"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -203,4 +203,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "工作列及開始功能表"
IDS_RESTORE_ALL "顯示開啟的視窗(&S)"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -204,4 +204,6 @@ STRINGTABLE
BEGIN
IDS_TASKBAR_STARTMENU_PROP_CAPTION "工作列及開始功能表"
IDS_RESTORE_ALL "顯示開啟的視窗(&S)"
IDS_TRAYWND_UNDO_CASCADE "&Undo Cascade"
IDS_TRAYWND_UNDO_TILE "&Undo Tile"
END

View file

@ -102,6 +102,8 @@
#define IDS_HELP_COMMAND 732
#define IDS_TASKBAR_STARTMENU_PROP_CAPTION 810
#define IDS_RESTORE_ALL 811
#define IDS_TRAYWND_UNDO_CASCADE 812
#define IDS_TRAYWND_UNDO_TILE 813
/*******************************************************************************\
|* Control Resources *|

View file

@ -58,6 +58,47 @@ void appbar_notify_all(HMONITOR hMon, UINT uMsg, HWND hwndExclude, LPARAM lParam
static const WCHAR szTrayWndClass[] = L"Shell_TrayWnd";
enum { NONE, TILED, CASCADED } g_Arrangement = NONE;
struct WINDOWPOSBACKUPDATA
{
HWND hwnd;
WINDOWPLACEMENT wplt;
};
CSimpleArray<WINDOWPOSBACKUPDATA> g_WindowPosBackup;
static BOOL CALLBACK BackupWindowsPosProc(HWND hwnd, LPARAM lParam)
{
WINDOWPOSBACKUPDATA wposdata;
HWND hDesk = GetDesktopWindow();
if (IsWindowVisible(hwnd) && !IsIconic(hwnd) && (hwnd != hDesk))
{
wposdata.hwnd = hwnd;
wposdata.wplt.length = sizeof(wposdata.wplt);
GetWindowPlacement(hwnd, &(wposdata.wplt));
g_WindowPosBackup.Add(wposdata);
}
return TRUE;
}
VOID BackupWindowPos()
{
EnumWindows(BackupWindowsPosProc, NULL);
}
VOID RestoreWindowPos()
{
g_Arrangement = NONE;
for (INT i = g_WindowPosBackup.GetSize() - 1; i >= 0; --i)
{
SetWindowPlacement(g_WindowPosBackup[i].hwnd, &(g_WindowPosBackup[i].wplt));
}
g_WindowPosBackup.RemoveAll();
}
struct EFFECTIVE_INFO
{
HWND hwndFound;
@ -805,6 +846,7 @@ public:
break;
case ID_SHELL_CMD_UNDO_ACTION:
RestoreWindowPos();
break;
case ID_SHELL_CMD_SHOW_DESKTOP:
@ -813,20 +855,35 @@ public:
case ID_SHELL_CMD_TILE_WND_H:
appbar_notify_all(NULL, ABN_WINDOWARRANGE, NULL, TRUE);
if (g_Arrangement == NONE)
{
BackupWindowPos();
}
TileWindows(NULL, MDITILE_HORIZONTAL, NULL, 0, NULL);
appbar_notify_all(NULL, ABN_WINDOWARRANGE, NULL, FALSE);
g_Arrangement = TILED;
break;
case ID_SHELL_CMD_TILE_WND_V:
appbar_notify_all(NULL, ABN_WINDOWARRANGE, NULL, TRUE);
if (g_Arrangement == NONE)
{
BackupWindowPos();
}
TileWindows(NULL, MDITILE_VERTICAL, NULL, 0, NULL);
appbar_notify_all(NULL, ABN_WINDOWARRANGE, NULL, FALSE);
g_Arrangement = TILED;
break;
case ID_SHELL_CMD_CASCADE_WND:
appbar_notify_all(NULL, ABN_WINDOWARRANGE, NULL, TRUE);
if (g_Arrangement == NONE)
{
BackupWindowPos();
}
CascadeWindows(NULL, MDITILE_SKIPDISABLED, NULL, 0, NULL);
appbar_notify_all(NULL, ABN_WINDOWARRANGE, NULL, FALSE);
g_Arrangement = CASCADED;
break;
case ID_SHELL_CMD_CUST_NOTIF:
@ -3281,12 +3338,30 @@ HandleTrayContextMenu:
::EnableMenuItem(hMenu, ID_SHELL_CMD_CASCADE_WND, MF_BYCOMMAND | MF_ENABLED);
::EnableMenuItem(hMenu, ID_SHELL_CMD_TILE_WND_H, MF_BYCOMMAND | MF_ENABLED);
::EnableMenuItem(hMenu, ID_SHELL_CMD_TILE_WND_V, MF_BYCOMMAND | MF_ENABLED);
if (g_Arrangement != NONE)
{
CStringW strCaption((g_Arrangement == TILED) ? MAKEINTRESOURCEW(IDS_TRAYWND_UNDO_TILE)
: MAKEINTRESOURCEW(IDS_TRAYWND_UNDO_CASCADE));
MENUITEMINFOW mii = { sizeof(mii) };
::GetMenuItemInfoW(hMenu, ID_SHELL_CMD_UNDO_ACTION, FALSE, &mii);
mii.fMask = MIIM_TYPE;
mii.fType = MFT_STRING;
mii.dwTypeData = const_cast<LPWSTR>(&strCaption[0]);
::SetMenuItemInfoW(hMenu, ID_SHELL_CMD_UNDO_ACTION, FALSE, &mii);
}
else
{
::DeleteMenu(hMenu, ID_SHELL_CMD_UNDO_ACTION, MF_BYCOMMAND);
}
}
else
{
::EnableMenuItem(hMenu, ID_SHELL_CMD_CASCADE_WND, MF_BYCOMMAND | MF_GRAYED);
::EnableMenuItem(hMenu, ID_SHELL_CMD_TILE_WND_H, MF_BYCOMMAND | MF_GRAYED);
::EnableMenuItem(hMenu, ID_SHELL_CMD_TILE_WND_V, MF_BYCOMMAND | MF_GRAYED);
::DeleteMenu(hMenu, ID_SHELL_CMD_UNDO_ACTION, MF_BYCOMMAND);
g_Arrangement = NONE;
g_WindowPosBackup.RemoveAll();
}
return 0;
}