@@ -1850,6 +1850,29 @@ class CMainWindow :
1850
1850
1851
1851
return CWindowImpl::Create (NULL , r, szWindowName.GetString (), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
1852
1852
}
1853
+
1854
+ void HandleTabOrder (int direction)
1855
+ {
1856
+ HWND Controls[] = { m_Toolbar->m_hWnd , m_SearchBar->m_hWnd , m_TreeView->m_hWnd , m_ListView->m_hWnd , m_RichEdit->m_hWnd };
1857
+ // When there is no control found, go to the first or last (depending on tab vs shift-tab)
1858
+ int current = direction > 0 ? 0 : (_countof (Controls) - 1 );
1859
+ HWND hActive = ::GetFocus ();
1860
+ for (int n = 0 ; n < _countof (Controls); ++n)
1861
+ {
1862
+ if (hActive == Controls[n])
1863
+ {
1864
+ current = n + direction;
1865
+ break ;
1866
+ }
1867
+ }
1868
+
1869
+ if (current < 0 )
1870
+ current = (_countof (Controls) - 1 );
1871
+ else if (current >= _countof (Controls))
1872
+ current = 0 ;
1873
+
1874
+ ::SetFocus (Controls[current]);
1875
+ }
1853
1876
};
1854
1877
1855
1878
VOID ShowMainWindow (INT nShowCmd)
@@ -1877,6 +1900,16 @@ VOID ShowMainWindow(INT nShowCmd)
1877
1900
{
1878
1901
if (!TranslateAcceleratorW (hMainWnd, KeyBrd, &Msg))
1879
1902
{
1903
+ if (Msg.message == WM_CHAR &&
1904
+ Msg.wParam == VK_TAB)
1905
+ {
1906
+ // Move backwards if shift is held down
1907
+ int direction = (GetKeyState (VK_SHIFT) & 0x8000 ) ? -1 : 1 ;
1908
+
1909
+ wnd->HandleTabOrder (direction);
1910
+ continue ;
1911
+ }
1912
+
1880
1913
TranslateMessage (&Msg);
1881
1914
DispatchMessageW (&Msg);
1882
1915
}
0 commit comments