You are currently offline, waiting for your Internet to reconnect

How-to: Handling CMFCOutlookBar Tab Change Notifications


The CMFCOutlookBar class has an underlying CMFCOutlookBarTabCtrl to which you can add tabs. These appear as tab page buttons in the CMFCOutlookBar.

If you call CMFCOutlookBar::SetMode2003 to set the Office 2003 UI mode then the CMFCOutlookBar will contain a toolbar window as well. In 2003 mode, if you collapse the tab page buttons by sliding the divider between the tab page buttons and the tab view pane then as each tab page button is removed, a corresponding toolbar button is added to the toolbar. Furthermore, if you size the entire CMFOutlookBar so that the window is not wide enough to display all of the toolbar buttons, then the toolbar chevron button context menu will contain a menu item for each tab page button that is not visible and does not have a toolbar button.

When you click the tab page button, or it's corresponding toolbar button, or it's corresponding chevron button menu item, the corresponding tab becomes the active tab displayed in the CMFCOutookBar. If you wish to do custom processing when the tab is changed you can handle the registered message AFX_WM_CHANGE_ACTIVE_TAB that is sent to your application main frame window.

More Information

AFX_WM_CHANGE_ACTIVE_TAB is a custom windows message registered by MFC in afxbasetabctrl.cpp. This message is sent to the main frame window when either:

  1. The active tab is changed by clicking on a tab page button. This message is not sent if the corresponding tab is currently active
  2. A CMFCOutlookBar toolbar button is clicked (2003 mode). This message is sent even if the corresponding tab is currently active
  3. A chevron button menu item is clicked (2003 mode). This message is sent even if the corresponding tab is currently active
The WPARAM message parameter will contain the zero based tab index of the clicked tab.
The LPARAM message parameter will contain the 'this' pointer of the CMFCOutlookBarTabCtrl object if you clicked a tab page button, or NULL for a toolbar button or chevron menu.

To handle the active tab change message you can add a message handler for this message in your mainframe window:

Here is the message map entry you need.


A possible OnChangeActiveTab handler:

LRESULT CMainFrame::OnChangeActiveTab(WPARAM wparam,LPARAM lparam)
CString message;
message.Format(_T("Tab %d clicked"),(int)wparam+1);
return 1;
Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Article ID: 2000702 - Last Review: 04/20/2010 22:00:00 - Revision: 1.0

Microsoft Visual Studio 2008 Service Pack 1

  • KB2000702
teElement('meta');'ms.dqp0';m.content='false';document.getElementsByTagName('head')[0].appendChild(m);" src="">