MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / SelectAdjacentTab

Method SelectAdjacentTab

source/script_gui.cpp:10220–10263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10218
10219
10220ResultType GuiType::SelectAdjacentTab(GuiControlType &aTabControl, bool aMoveToRight, bool aFocusFirstControl
10221 , bool aWrapAround)
10222{
10223 int tab_count = TabCtrl_GetItemCount(aTabControl.hwnd);
10224 if (!tab_count)
10225 return FAIL;
10226
10227 int selected_tab = TabCtrl_GetCurSel(aTabControl.hwnd);
10228 if (selected_tab == -1) // Not sure how this can happen in this case (since it has at least one tab).
10229 selected_tab = aMoveToRight ? 0 : tab_count - 1; // Select the first or last tab.
10230 else
10231 {
10232 if (aMoveToRight) // e.g. Ctrl-PgDn or Ctrl-Tab, right-arrow
10233 {
10234 ++selected_tab;
10235 if (selected_tab >= tab_count) // wrap around to the start
10236 {
10237 if (!aWrapAround)
10238 return FAIL; // Indicate that tab was not selected due to non-wrap.
10239 selected_tab = 0;
10240 }
10241 }
10242 else // Ctrl-PgUp or Ctrl-Shift-Tab
10243 {
10244 --selected_tab;
10245 if (selected_tab < 0) // wrap around to the end
10246 {
10247 if (!aWrapAround)
10248 return FAIL; // Indicate that tab was not selected due to non-wrap.
10249 selected_tab = tab_count - 1;
10250 }
10251 }
10252 }
10253 // MSDN: "A tab control does not send a TCN_SELCHANGING or TCN_SELCHANGE notification message
10254 // when a tab is selected using the TCM_SETCURSEL message."
10255 TabCtrl_SetCurSel(aTabControl.hwnd, selected_tab);
10256 ControlUpdateCurrentTab(aTabControl, aFocusFirstControl);
10257
10258 // Fix for v1.0.35: Keyboard navigation of a tab control should still launch the tab's event handler
10259 // if it has one:
10260 Event(GUI_HWND_TO_INDEX(aTabControl.hwnd), TCN_SELCHANGE);
10261
10262 return OK;
10263}
10264
10265
10266

Callers 1

MsgSleepFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected