https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dee771817e11d56f33e2c01ec67f3ab92b795221

commit dee771817e11d56f33e2c01ec67f3ab92b795221
Author:     Mark Jansen <[email protected]>
AuthorDate: Sun Feb 9 17:54:18 2020 +0100
Commit:     Mark Jansen <[email protected]>
CommitDate: Sun Feb 23 17:52:05 2020 +0100

    [RAPPS] Allow tabbing trough controls in the main window
---
 base/applications/rapps/gui.cpp | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/base/applications/rapps/gui.cpp b/base/applications/rapps/gui.cpp
index ad2a13f9a9f..182d1068665 100644
--- a/base/applications/rapps/gui.cpp
+++ b/base/applications/rapps/gui.cpp
@@ -1850,6 +1850,29 @@ public:
 
         return CWindowImpl::Create(NULL, r, szWindowName.GetString(), 
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
     }
+
+    void HandleTabOrder(int direction)
+    {
+        HWND Controls[] = { m_Toolbar->m_hWnd, m_SearchBar->m_hWnd, 
m_TreeView->m_hWnd, m_ListView->m_hWnd, m_RichEdit->m_hWnd };
+        // When there is no control found, go to the first or last (depending 
on tab vs shift-tab)
+        int current = direction > 0 ? 0 : (_countof(Controls) - 1);
+        HWND hActive = ::GetFocus();
+        for (int n = 0; n < _countof(Controls); ++n)
+        {
+            if (hActive == Controls[n])
+            {
+                current = n + direction;
+                break;
+            }
+        }
+
+        if (current < 0)
+            current = (_countof(Controls) - 1);
+        else if (current >= _countof(Controls))
+            current = 0;
+
+        ::SetFocus(Controls[current]);
+    }
 };
 
 VOID ShowMainWindow(INT nShowCmd)
@@ -1877,6 +1900,16 @@ VOID ShowMainWindow(INT nShowCmd)
     {
         if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
         {
+            if (Msg.message == WM_CHAR &&
+                Msg.wParam == VK_TAB)
+            {
+                // Move backwards if shift is held down
+                int direction = (GetKeyState(VK_SHIFT) & 0x8000) ? -1 : 1;
+
+                wnd->HandleTabOrder(direction);
+                continue;
+            }
+
             TranslateMessage(&Msg);
             DispatchMessageW(&Msg);
         }

Reply via email to