A multi document tabbed interface






4.69/5 (11 votes)
Jan 30, 2000

251192

7094
A variation on the MDI that indicates the open child windows in a tab control.

We have introduced a new interface extension for MDI (multiple document interface) based applications - MDI tabbed interface or MTI. This class is part of the Ultimate Toolbox class library and can be used freely.
We haven't changed anything in the relationships between the main frame window (MDIFrame window) and its children (MDIChild windows). We added functionality that is usually overlooked when developing MDI applications.
The MDIClient window which resides in the client area of the MDIFrame window manages MDIChild windows. Instead of just displaying the MDIClient window we also display a standard tab control (hence tabbed MDI) in which we create an item for every MDIChild window. The window icon and text will be associated with the corresponding tab item.
Using the tab control you can switch quickly between MDIChild windows by just clicking on the tab item. If you double click over a tab item, the corresponding MDIChild window will be maximized/restored. And, finally, when any object is dragged over the tab control items (using standard OLE drag and drop) the corresponding MDIChild window will be activated.
We use a standard tab control so you can customize its appearance using the standard set of relevant functions (refer for CTabCtrl description in the MFC documentation).
We developed three classes in order to provide the above described functionality:
COXTabWorkspaceDropTarget | COleDropTarget derived class used to support the changing of active MDIChild when any object is dragged over tab control items (This is an internal class) |
COXTabWorkspace | CTabCtrl derived class. Covers MDIClient area. For every MDIChild window there will be the tab item that will use window text and icon as item text and icon. Whenever you click on the item the coresponding child window will be activated. Whenever you double click on the item the corresponding MDIChild window will be maximized/restored |
COXTabClientWnd | CWnd derived class. Subclasses MDIClient window. Manages the
placement of the MDIClient and tab control regarding each other.
|
Almost all the logic of the classes is implemented internally and there are few public members. Refer to COXTabWorkspace reference for the list of functions available to customize the tab control appearance.
COXTabClientWnd class has a few public functions (refer to COXTabClientWnd reference for details) but primarily you will be interested in the following ones:
Attach()
Detach()
Below you two steps that should be taken in order to implement tabbed MDI interface in your MDI application
- In your CMainFrame class declare variable of
COXTabClientWnd
class:COXTabClientWnd m_MTIClientWnd;
- In your
CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
function implementation add the following line of code:m_MTIClientWnd.Attach(this);
That's it.
Sample
The TabbedMDI project included in the samples directory shows the class in action. There you will see how you can customize the tabbed MDI interface appearance.
COXTabWorkspace
SetOffset |
|
GetOffset |
|
AcceptDraggedObject |
|
IsAcceptingDraggedObject
|
|
void SetOffset(const DWORD dwOffset)
Parameters
dwOffset |
|
Remarks
Sets the tab control offset from MDIFrame client area borders
DWORD GetOffset() const
Return Value
offset in points from the MDIFrame window client area where the tab control will be displayed
Remarks
Retrievs the tab control offset from MDIFrame borders
void AcceptDraggedObject(const BOOL bAccept=TRUE)
Parameters
bAccept | if TRUE then when any object is dragged over tab items the corresponding MDIChild windows will be activated |
Remarks
Set/Remove drag over object support for the tab control
BOOL IsAcceptingDraggedObject() const
Parameters
bAccept |
if TRUE then when any object is dragged over tab items the corresponding MDIChild windows will be activated |
Return Value
TRUE if when any object is dragged over tab items the corresponding MDIChild windows will be activated
COXTabClientWnd
Attach |
|
Detach |
|
IsAttached |
|
GetTabCtrl |
|
GetParentFrame |
|
BOOL Attach(const CMDIFrameWnd* pParentFrame, DWORD dwTabCtrlStyle=DEFAULT_TABCTRLSTYLE)
Parameters
pParentFrame | pointer to MDIFrame window of the application | |
dwTabCtrlStyle | tab control styles that will be used while creating the tab control. Refer to the Windows SDK documentation for list of all available styles. The following styles are used by default: | |
TCS_MULTILINE TCS_BOTTOM TCS_HOTTRACK TCS_SCROLLOPPOSITE TCS_RIGHTJUSTIFY |
Return Value
TRUE if success or FALSE otherwise.
Remarks
Substitutes the standard MDI interface with enhanced tabbed MDI
BOOL Detach()
Return Value
TRUE if successful or FALSE otherwise.
Remarks
Restore the standard MDI interface
BOOL IsAttached() const
Return Value
TRUE if the tabbed MDI interface is active.
Remarks
Retrieves the flag that specifies whether the standard MDI interface was
substituted with enhanced tabbed MDI or not.
COXTabWorkspace* GetTabCtrl()
Return Value
pointer to the tab control
Remarks
Retrieves pointer to the tab control
CMDIFrameWnd* GetParentFrame()
Return Value
pointer to the parent MDIFrame window or NULL if none was attached
Remarks
Retrieves pointer to the parent MDIFrame window