If you want to catch the post tab change, the tab that will be active, need AFX_WM_CHANGE_ACTIVE_TAB ie;
ON_REGISTERED_MESSAGE(AFX_WM_CHANGE_ACTIVE_TAB,OnTabSetActive)
LRESULT CYourClass::OnTabSetActive(WPARAM wParam, LPARAM lParam)
{
const int iActiveTab = (int)wParam;
int iCheckActiveTab = m_wndTabs.GetActiveTab(); //CMFCTabCtrl m_wndTabs;
m_wndTabs.SetActiveTab(iActiveTab); //good idea to also add this depending on usage.
return 0;
}
And if you require manually changing the tab call using;
SendMessage(AFX_WM_CHANGE_ACTIVE_TAB, iTabNum2ChangeTo, 0);
Posted the above after trying to find a solution to my problem where using
CMFCTabCtrl::SetActiveTab()
would crash but in debug mode only. And this OP was googles top answer.
AFX_WM_CHANGING_ACTIVE_TAB appears to catch the event prior to the actual tab change, hence why hasn't worked for the OP, and can be checked by;
int iCheckActiveTab = m_wndTabs.GetActiveTab();