Makes the specified tab the new active tab.
C
int SftTabs_SetCurrentTab(HWND hwndCtl, int iTab);
C++
int CSftTabs::SetCurrentTab(int iTab);
hwndCtl
The window handle of the tab control.
iTab
The zero-based index of the tab to be activated. All tabs can be deactivated by specifying -1 (based on the settings defined by SetAllowAllInactive).
The return value is the index of the new active tab, otherwise -1 is returned.
The SetCurrentTab function makes the specified tab the new active tab.
When using this function to activate a new tab, the tab control sends a SFTTABSN_SWITCHING notification (the application can cancel the switch by sending a WM_CANCELMODE message to the tab control, in which case -1 is returned), followed by a SFTTABSN_SWITCHED notification once the new tab is active, so the normal tab switching mechanism takes place, such as calling the SFTTABS_TABCALLBACK tab callback function, the CSftTabsPage::AllowSwitch or CSftTabsWindowPage::AllowSwitch member functions of the C++ based implementation of tabbed dialog. No notifications are sent if the specified tab is already active.
A disabled tab cannot be activated. Use SetCurrentTabEx to activate a disabled tab.
This example makes the third tab the new active tab:
C
SftTabs_SetCurrentTab(hwndTab, 2);
C++
m_Tab.SetCurrentTab(2);
HWND hwndCtl = (HWND) lParam;
int id = LOWORD(wParam);
int code = HIWORD(wParam);
if (hwndCtl) {
switch (id) {
case IDC_P4_NEXT: {
HWND hwndTab = SftTabs_GetTabControlFromPage(hwndDlg);
int iTab = SftTabs_GetCurrentTab(hwndTab);
SftTabs_SetCurrentTab(hwndTab, iTab+1);
break;
}
case IDC_P4_PREVIOUS: {
HWND hwndTab = SftTabs_GetTabControlFromPage(hwndDlg);
int iTab = SftTabs_GetCurrentTab(hwndTab);
SftTabs_SetCurrentTab(hwndTab, iTab-1);
break;
void CWizDlg::OnNext()
{
int index = m_Tab.GetCurrentTab();
if (index >= m_Tab.GetCount()-1)
// last page, finish
OnOK();
else
// make next tab active
m_Tab.SetCurrentTab(index+1);
}
void CWizDlg::OnBack()
{
int index = m_Tab.GetCurrentTab();
if (index <= 0) {
ASSERT(0); // Back button should not have been enabledSee Also C/C++ API | C++ Classes | Notifications