I created tabs:

hTabCtrl=CreateWindow(WC_TABCONTROL, "", WS_VISIBLE|WS_TABSTOP|WS_CHILD|TCS_FOCUSONBUTTONDOWN ,0,0,0,0,hWnd, (HMENU)ID_TAB, hInst, NULL ); mOb.SetDefaultFont(hTabCtrl); hTabCtrl = GetDlgItem(hWnd, ID_TAB); tci.mask=TCIF_TEXT; tci.iImage=-1; // Create Three Tabs tci.pszText = "Главная"; TabCtrl_InsertItem(hTabCtrl,0,&tci); tci.pszText = "Two"; TabCtrl_InsertItem(hTabCtrl,1,&tci); 

Can you please tell me how to switch between tabs programmatically? Those. switch from the first to the second tab and back.

  • I just already, as soon as I didn’t try, where I can’t find how to do it ... - shc345
  • Nothing better than sending WM_KEYDOWN with VK_LEFT or VK_RIGHT I did not find in the documentation. Try SendMessage (hTabCtrl, WM_KEYDOWN, VK_RIGHT, 0). - dzhioev

2 answers 2

If you search on MSDN: MSDN TabControl

Then you can find the macro TabCtrl_SetCurSel and TCM_SETCURSEL

    Yes, indeed, one might think that such a question does not exist at all. Somehow it is ignored, perhaps ... Or maybe it’s necessary to use it as an event handler, after creating the second tab, like:

     hTwoTabCtrl = CreateWindow( WC_TABCONTROL, "", WS_VISIBLE | WS_TABSTOP | WS_CHILD | TCS_FOCUSONBUTTONDOWN, 0, 0, 0, 0, hWnd, (HMENU)ID_TWOTAB, hInst, NULL); 

    and then, when the corresponding WM_COMMAND message WM_COMMAND from Windows, check in the handler, what is there specifically in the word wParam ?