visual-c++mfcmfc-feature-pack

CMFCTabCtrl catch tab change event


I want to catch the tab change event of a CMFCTabCtrl. Below is the code I'm trying to do that. But it does not catch the change event.

BOOL SurvChatDlg::OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* 
                               pResult ) 
{ 
if(((LPNMHDR)lParam)->code==TCN_SELCHANGE) 
{ 
    int i = m_TabControl.GetActiveTab();
    AfxMessageBox("Changed");
} 
return CDialog::OnNotify( wParam, lParam, pResult ); 
}

Solution

  • According to this forum thread, you need to handle the AFX_WM_CHANGING_ACTIVE_TAB message sent to the parent window.

    This forum thread has more code samples.