From d9c5a84ec598b95b9b5e0699c408a69a3f6a15a0 Mon Sep 17 00:00:00 2001 From: xrmb Date: Sat, 4 Jul 2026 23:07:14 -0400 Subject: [PATCH] Forward Total Commander Lister view-mode keys (1-8) to the parent Lister window The IE WebBrowser control and the RichEdit raw-source pane were consuming the WM_KEYDOWN messages for the digit keys 1-8, which Total Commander uses to switch between Lister view modes. Intercept those keys in the subclassed window procedures and post them to the Lister window (the parent of the plugin container) so TC can handle them again. Fixes the 1-8 view-mode shortcuts while keeping the plugin's own Ctrl+* hotkeys and internal navigation intact. --- mdview.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mdview.c b/mdview.c index 23f6a9a..e20d480 100644 --- a/mdview.c +++ b/mdview.c @@ -270,11 +270,24 @@ static wchar_t* utf8_to_wide_dup(const char* s) { return w; } +/* Forward a key message to the Lister window (parent of our container) so + Total Commander can handle its own view-mode shortcuts (1-7 etc.) */ +static void forward_key_to_lister(MDViewData* d, WPARAM wP, LPARAM lP) +{ + HWND w = d ? GetParent(d->hwndContainer) : NULL; + if (w) PostMessageW(w, WM_KEYDOWN, wP, lP); +} + static LRESULT CALLBACK TextViewSubclassProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP) { MDViewData* d = (MDViewData*)GetPropW(hwnd, L"MDViewData"); if (!d) return DefWindowProcW(hwnd, msg, wP, lP); if (msg == WM_KEYDOWN) { int ctrl = GetKeyState(VK_CONTROL) & 0x8000; + int alt = GetKeyState(VK_MENU) & 0x8000; + if (!ctrl && !alt && ((wP >= '1' && wP <= '8') || (wP >= VK_NUMPAD1 && wP <= VK_NUMPAD8))) { + forward_key_to_lister(d, wP, lP); + return 0; + } if (ctrl) { if (wP == 'M') { toggle_split_view(d); return 0; } if (wP == 'C') { SendMessageW(hwnd, WM_COPY, 0, 0); return 0; } @@ -335,6 +348,11 @@ static LRESULT CALLBACK IEServerSubclassProc(HWND hwnd, UINT msg, WPARAM wP, LPA if (msg == WM_KEYDOWN) { int ctrl = GetKeyState(VK_CONTROL) & 0x8000; + int alt = GetKeyState(VK_MENU) & 0x8000; + if (!ctrl && !alt && ((wP >= '1' && wP <= '8') || (wP >= VK_NUMPAD1 && wP <= VK_NUMPAD8))) { + forward_key_to_lister(d, wP, lP); + return 0; + } if (ctrl) { switch (wP) { case VK_OEM_PLUS: case VK_ADD: