Click here to Skip to main content
15,891,184 members
Articles / Desktop Programming / WTL

Custom Tab Controls, Tabbed Frame and Tabbed MDI

Rate me:
Please Sign up or sign in to vote.
4.90/5 (144 votes)
13 Jul 200522 min read 1.6M   35.6K   395  
An extensible framework for creating customized tabs in ATL/WTL, with a VS.NET-like tab control implementation, tabbed frames, tabbed MDI, and more.
// History of TabbedFrame.h prior to codeproject article about it
//
// History (Date/Author/Description):
// ----------------------------------
//
// 2002/06/12: Daniel Bowen (DDB)
// - CCoolTabOwnerImpl:
//   * Don't use extra boolean "m_bTabAreaOnTop".  Just depend on "bottom" style.
//   * CreateTabWindow: Allow custom tab control styles to be passed in
//   * DisplayTab: Fix bug where "ShowTabs" was only being called if the
//     window being added had window text
//   * Rename to CCustomTabOwnerImpl
//   * "SetTabAreaHeight" and "CalcTabAreaHeight" as "overrideable" methods
//   * "GetTabAreaHeight"
//   * Call pT->CalcTabAreaHeight(); in CreateTabWindow
//   * Don't reference CCoolTabItem directly, reference TTab::TItem
//     (which now is more likely to be CTabViewTabItem)
// - CTabbedFrameImpl:
//   * Notifications don't have to be reflected, but the user might still
//     want them reflected (if subclassing a common control window for example)
//     Expose "SetReflectNotifications" and "GetReflectNotifications"
//   * Update "TCN_*" to "CTCN_*"
//   * "UpdateTabAreaHeight" is now in CCustomTabOwnerImpl::CalcTabAreaHeight
//   * Override new "SetTabAreaHeight" to update layout and invalidate
// - CTabbedPopupFrame:
//   * Don't have "_Top" as a template parameter.
//   * In the constructor, allow the client to indicate they want
//     notifications reflected
//
// 2002/04/30: Daniel Bowen (DDB)
// - CTabbedFrameImpl - handle WM_FORWARDMSG by forwarding the
//   message to the active tab view.
//
// 2002/04/23: Daniel Bowen (DDB)
// - New "CCoolTabItem" class used instead of TCITEM.
//   See "CoolTabCtrls.h" for an explanation.
// - New CCoolTabOwnerImpl::UpdateTabToolTip
// - New CCoolTabOwnerImpl::UpdateTabImage
// - ATL 7 compatibility issues pointed out to me by
//   Ramon Casellas [casellas@infres.enst.fr]
//
// 2002/04/22: Daniel Bowen (DDB)
// - CCoolTabOwnerImpl: Add several more methods for getting an image
//   into the image list and associated with a tab.  With the updates,
//   you can now more easily add images independant of adding a tab.
//   IMPORTANT: If you've used this code in the past, its important
//    to use "AddTabWithIcon" instead of "AddTab" if you are adding
//    a tab with a resource identifier of an icon.
// - CTabbedFrameImpl: Make the tab area height dependant on
//   the same metrics that the font of the tabs depends on.
//
// 2002/04/05: Daniel Bowen (DDB)
// - Update CTabbedFrameImpl::OnSetFocus to not check for
//   IsWindowVisible(m_hWndActive).  When the frame is maximized,
//   ::IsWindowVisible(m_hWndActive) will return FALSE,
//   which results in the focus not being forwarded
//   to the active tab window.
//   See http://www.codeproject.com/useritems/WTLMDIChildMax.asp
//   for an explanation.

// 2002/03/13: Daniel Bowen (DDB)
// - Remove notification handler for NM_RCLICK from CTabbedFrameImpl.
//   The implementation is correct when a tree view is the active child,
//   but not necessarily for other windows (most notibly a list view).
//   Since notifications are getting reflected back anyway, let the
//   child deal with NM_RCLICK as appropriate

// 2002/03/11: Daniel Bowen (DDB)
// - CTabbedFrameImpl:
//   * Added handler for WM_SETFOCUS to set focus to active child
//     (similar to how CFrameWindowImplBase::OnSetFocus does it
//      in the normal case when there's a child/client window)
//   * For key messages, if the baseClass message map hasn't
//      handled it, re-send the message to the active child window

// 2002/02/07: Daniel Bowen (DDB)
// - New CCoolTabOwnerImpl MI class resulting from
//   refactoring due to commonality that existed between
//   CTabbedFrameImpl and CMDITabOwner.  Use this
//   class to help implement a windowing class that
//   will contain a CoolTabCtrl.
// 
// 2002/01/31: Daniel Bowen (DDB)
// - Original Release
//

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect
United States United States
Daniel Bowen used to work as a Software Engineer for Evans & Sutherland in Salt Lake City, Utah working on the modeling tools for high end flight simulators. He then worked for the startup company WiLife Inc. in Draper, Utah working on the software portion of an easy to use and affordable digital video surveillance system. WiLife Inc. is now part of Logitech Inc.

Comments and Discussions