Click here to Skip to main content
Click here to Skip to main content

Tab Controls And Splitters - Adding Some Dockable And Floating Sugar

By , 6 Jan 2004
 

Tab Controls And Splitters - Adding Some Dockable And Floating Sugar

Introduction

In the previous article, I introduced SplitPane class that manages client view windows with splitters and tab panes and provides an interaction interface with the owner class. In this article, I would like to represent Frame class that extends SplitPane functionality with dockable and floating features. Also, I am going to consider that you know what dockable and floating windows are. Sure, the best example of those is Visual Studio .NET IDE. I guess you are also aware of an excellent job that has been done by Sergey Klimov and the further improvement by Daniel Bowen. This article is just an attempt to provide a simpler interface for the particular case, with a little bit different paradigm. I hope I have succeeded in it.

What it does

Briefly: Frame class provides dockable and floating environment for client views. There are three parts to this environment, the main pane, dock panes and float frames. All of them are owners of SplitPane, so you can split and tab all client views. Also, the client views are separated in two different groups, dockable views and document views. The difference is simple. The dockable views cannot be attached in the main pane but can be docked in one of the docked sides. The document views are unlike them, they can be attached in the main pane but cannot be docked. Both of them are able to become floating. That's the difference with Visual Studio .NET IDE. To prevent a floating window to get docked to any place, keep CTRL key pressed while dragging it.

Using the code

The use of Frame class can be as simple as the use of SplitPane class. It's also designed for SDI applications. I won't repeat all steps but a few points. With all include files mentioned in that, you will want to use DockTabFrame.h with the Frame class implementation. This is also in DockSplitTab namespace. There is a ClientView class that has all necessary properties for the client view windows. Frame class provides a communication interface for the interface with the owner or parent class. This is the FrameListener abstract class. clientDetached is the only function provided for this interface so far. Frame class calls it when a user closes a dock pane, a float frame or a tab. In other words, when he pushes a close button. There is a detachClientView function for Frame class that does the similar action but does not raise clientDetached event. Frame sends WM_CONTEXTMENU Windows message to the client views in appropriate cases. For instance, when you click a right mouse button on the tab.

Frame class

Public methods:

// creates a new Split Pane window with parentWnd and rect parameters
HWND create( parentWnd, rect);

// sets the keyboard focus to the specified client view window
bool setFocusTo( clientViewWnd) {

// retrieves the client view window that receives the keyboard focus
HWND focusedClientView();

// toggles client view state and move
// the client view to an appropriate pane
bool toggleClientViewState( clientViewWnd, ClientView::State);

// retrieves client view properties with client view window handle
ClientView* getClientView( clientViewWnd);

// adds a new client view
bool addClientView( clientView);

// adds a new client view and attach it to the specified dock pane
bool dockClientView( dockSide, clientView);

// shows/hides the specified dock pane
bool showDockPane( dockSide, show);

// retrieves the visibility state of the specified dock pane
bool dockPaneVisible( dockSide);

// retrieves the existence state of the specified dock pane
bool dockPaneExists( dockSide);

// float frame iterator functions
POSITION floatFrameStart()
HWND floatFrameNext( &position);

// adds a new client view and attach it to a new float frame
// with the specified location
HWND floatClientView( rect, clientView);

// retrieves the visibility state of the specified float frame
bool showFloatFrame( floatFrameWnd, show);

// check if a float frame is visible
bool floatFrameVisible( floatFrameWnd)

// check if a float frame exists
bool checkFloatFrame( floatFrameWnd);

// reattach the client view. the function uses
// the last location object propertes
void attachClientView( clientView);

// detaches the client view window 
// This method changes the parent window of the client
// view window to the Frame's parent.
ClientView* detachClientView( clientViewWnd);

// retrieves the visibility state of the specified client view window handle
bool clientViewVisible( clientViewWnd);

// checks if client view window is attached.
bool clientViewAttached( clientViewWnd);

// set and get Image List
void setImageList( imgList);
HIMAGELIST getImageList();

Inside of Frame class

There are implementations of two very important classes for Frame class. These are DockPane class and FloatFrame class. Each of them has its own SplitPane member. So you can split and tab client views inside of each DockPane or FloatFrame instance. Frame class itself also owns SplitPane instance. An objective of this instance is to keep document views. Frame class communicates with the float frames, dock panes and main pane via FloatDockFrameListener interface class that extends CallBackListener interface.

class DockPane - contains docked client views.
class FloatFrame - contains floating client views.
class FloatDockFrameListener - communication interface between float frames, dock panes and their owner. (Frame class)
class SplitPaneWrapper

- encapsulates common data and methods for split pane containers.

Used by FloatFrame class and DockPane class.

class FloatFrameDragContext - stores drag and drop context. Inherited from RectTracker class.
class DropParcel -the result of drag and drop operations.
class LayoutManager - layout implementation for Frame class.

What's the next

Two things are left to do: Serialization and Auto hide panes.

References

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

About the Author

Igor Katrayev
Web Developer
United States United States
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionCompile error in VC++ 2005memberMember 2550674 Jan '08 - 4:11 
1>External build tool process set to low priority...
1>DockTabFrameWork.cpp
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\dotnettabctrl.h(1073) : error C3203: “CDotNetButtonTabCtrl”: ?????? ?? ???? ?? ??,????? ?? ??“T”,?? real ??
1> e:\vc_work\wtl\docktabframe\docktabframe_demo\include\dotnettabctrl.h(1511): ????????? ?? ???“CDotNetButtonTabCtrl”???
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\dotnettabctrl.h(1515) : error C3203: “CDotNetTabCtrl”: ?????? ?? ???? ?? ??,????? ?? ??“T”,?? real ??
1> e:\vc_work\wtl\docktabframe\docktabframe_demo\include\dotnettabctrl.h(1535): ????????? ?? ???“CDotNetTabCtrl”???
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2053) : error C2885: “stateNull”: ??????????? using ??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2054) : error C2885: “stateDockable”: ??????????? using ??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2055) : error C2885: “stateFloating”: ??????????? using ??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2340) : error C2885: “stateDockable”: ??????????? using ??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2341) : error C2885: “stateFloating”: ??????????? using ??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2342) : error C2885: “stateNull”: ??????????? using ??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2344) : error C2065: “stateNull”: ???????
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2397) : error C2065: “stateDockable”: ???????
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2404) : error C2065: “stateFloating”: ???????
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2451) : error C2051: case ???????
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2454) : error C2051: case ???????
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2457) : warning C4060: switch ??????“case”?“default”??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(2887) : error C2065: “i”: ???????
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(3514) : error C2885: “stateFloating”: ??????????? using ??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\include\docktabframe.h(3515) : error C2885: “stateDockable”: ??????????? using ??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\docktabframework\clientwindowlistview.h(15) : error C2885: “stateDockable”: ??????????? using ??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\docktabframework\clientwindowlistview.h(16) : error C2885: “stateFloating”: ??????????? using ??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\docktabframework\clientwindowlistview.h(157) : error C2885: “stateDockable”: ??????????? using ??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\docktabframework\clientwindowlistview.h(158) : error C2885: “stateFloating”: ??????????? using ??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\docktabframework\clientwindowlistview.h(161) : error C2051: case ???????
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\docktabframework\clientwindowlistview.h(162) : error C2051: case ???????
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\docktabframework\clientwindowlistview.h(165) : warning C4060: switch ??????“case”?“default”??
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\docktabframework\clientwindowlistview.h(188) : error C2051: case ???????
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\docktabframework\clientwindowlistview.h(189) : error C2051: case ???????
1>e:\vc_work\wtl\docktabframe\docktabframe_demo\docktabframework\clientwindowlistview.h(192) : warning C4060: switch ??????“case”?“default”??
1>NewWtlDlg.cpp
1>??????...
1>??????????...
1>External build tool process set to low priority...
1>Microsoft ?????????? Version 8.00.50727
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>???????“file://e:\Vc_work\Wtl\docktabframe\docktabframe_demo\DockTabFrameWork\Debug\BuildLog.htm”
1>DockTabFrameWork - 24 ???,3 ???
========== ??: 0 ???, 1 ???, 0 ??, 0 ??? ==========

AnswerRe: Compile error in VC++ 2005memberwin32sdk5 Mar '09 - 23:08 
this one availiable under vs2005 and wtl80:
http://download.csdn.net/source/1076882
GeneralWM_USER_DESTROY_PANE should be "Post" instead of "Send"memberQuynh Nguyen20 Sep '07 - 0:01 
In "detachClientView" method, should we use "PostMessage" instead of "SendMessage"?
QuestionHow to change Tab caption?memberQuynh Nguyen19 Sep '07 - 18:36 
After a window/control is added into the container (SplitPane::append), how can we change its caption later then?
 
Thanks.
GeneralProblem with using tab control between 2 panes in VC++memberShraddha Gautam14 Dec '06 - 19:50 
Hello everybody,
I have developed a VC++ application in which i have used a splitter window. I am not able to move from 1 pane to the other using a keyboard.
Can someone please help me with this. I also want to know how do i move from th menu bar to the window using shortkeys.
 

Thanx in advance,
 

 
Regards,
Shraddha
Generalprint the focus tabmemberztkx2 Nov '06 - 2:52 
how to get the focus tab, because I need to print the tab which get focus
Questionit breaks in VC++ 8member2simple17 Sep '06 - 9:35 
many examples break in VC8, sigh... i know it's the problem of the differences between different versions of VCs. as i'm still quite a rookie, i need help to figure out what's wrong... thanks.
 
Error messages are at the end of this post. I tried to commented out #include "atlgdix.h" in DockTabPane.h, then the compiler complained: ...\splitpane_demo\include\customtabctrl.h(122) : fatal error C1189: #error :   CustomTabCtrl.h requires atlgdix.h to be included first
 
if I even commented out the requiring indicatives in CustomTabCtrl.h, then of couse many other errors emerged.
 
Anyway, here are the error messages when compiling the original code with the change noted in http://www.codeproject.com/wtl/docktabframe.asp?df=100&forumid=31050&exp=0&select=741964#xx741964xx had been made (on the order of included header files in stdafx.h):
 
------ Build started: Project: SplitPaneDemo, Configuration: Debug Win32 ------
Compiling...
stdafx.cpp
Compiling...
MainFrm.cpp
C:\samples\splitpane_demo\include\atlgdix.h(201) : error C2953: 'WTL::CIconT' : class template has already been defined
            c:\programs\wtl75\include\atluser.h(871) : see declaration of 'WTL::CIconT'
C:\samples\splitpane_demo\include\atlgdix.h(203) : error C2371: 'WTL::CIcon' : redefinition; different basic types
            c:\programs\wtl75\include\atluser.h(874) : see declaration of 'WTL::CIcon'
C:\samples\splitpane_demo\include\atlgdix.h(204) : error C2371: 'WTL::CIconHandle' : redefinition; different basic types
            c:\programs\wtl75\include\atluser.h(873) : see declaration of 'WTL::CIconHandle'
C:\samples\splitpane_demo\include\atlgdix.h(326) : error C2953: 'WTL::CCursorT' : class template has already been defined
            c:\programs\wtl75\include\atluser.h(1033) : see declaration of 'WTL::CCursorT'
C:\samples\splitpane_demo\include\atlgdix.h(328) : error C2371: 'WTL::CCursor' : redefinition; different basic types
            c:\programs\wtl75\include\atluser.h(1036) : see declaration of 'WTL::CCursor'
C:\samples\splitpane_demo\include\atlgdix.h(329) : error C2371: 'WTL::CCursorHandle' : redefinition; different basic types
            c:\programs\wtl75\include\atluser.h(1035) : see declaration of 'WTL::CCursorHandle'
C:\samples\splitpane_demo\include\atlgdix.h(335) : error C2011: 'WTL::CLogFont' : 'class' type redefinition
            c:\programs\wtl75\include\atlgdi.h(360) : see declaration of 'WTL::CLogFont'
C:\samples\splitpane_demo\include\dotnettabctrl.h(1073) : error C3203: 'CDotNetButtonTabCtrl' : unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type
            C:\samples\splitpane_demo\include\dotnettabctrl.h(1511) : see reference to class template instantiation 'CDotNetButtonTabCtrl<TItem>' being compiled
C:\samples\splitpane_demo\include\dotnettabctrl.h(1515) : error C3203: 'CDotNetTabCtrl' : unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type
            C:\samples\splitpane_demo\include\dotnettabctrl.h(1535) : see reference to class template instantiation 'CDotNetTabCtrl<TItem>' being compiled
C:\samples\splitpane_demo\splitpanedemo\mainfrm.h(30) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\samples\splitpane_demo\splitpanedemo\mainfrm.h(31) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
SplitPaneDemo.cpp
C:\samples\splitpane_demo\include\atlgdix.h(201) : error C2953: 'WTL::CIconT' : class template has already been defined
            c:\programs\wtl75\include\atluser.h(871) : see declaration of 'WTL::CIconT'
C:\samples\splitpane_demo\include\atlgdix.h(203) : error C2371: 'WTL::CIcon' : redefinition; different basic types
            c:\programs\wtl75\include\atluser.h(874) : see declaration of 'WTL::CIcon'
C:\samples\splitpane_demo\include\atlgdix.h(204) : error C2371: 'WTL::CIconHandle' : redefinition; different basic types
            c:\programs\wtl75\include\atluser.h(873) : see declaration of 'WTL::CIconHandle'
C:\samples\splitpane_demo\include\atlgdix.h(326) : error C2953: 'WTL::CCursorT' : class template has already been defined
            c:\programs\wtl75\include\atluser.h(1033) : see declaration of 'WTL::CCursorT'
C:\samples\splitpane_demo\include\atlgdix.h(328) : error C2371: 'WTL::CCursor' : redefinition; different basic types
            c:\programs\wtl75\include\atluser.h(1036) : see declaration of 'WTL::CCursor'
C:\samples\splitpane_demo\include\atlgdix.h(329) : error C2371: 'WTL::CCursorHandle' : redefinition; different basic types
            c:\programs\wtl75\include\atluser.h(1035) : see declaration of 'WTL::CCursorHandle'
C:\samples\splitpane_demo\include\atlgdix.h(335) : error C2011: 'WTL::CLogFont' : 'class' type redefinition
            c:\programs\wtl75\include\atlgdi.h(360) : see declaration of 'WTL::CLogFont'
C:\samples\splitpane_demo\include\dotnettabctrl.h(1073) : error C3203: 'CDotNetButtonTabCtrl' : unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type
            C:\samples\splitpane_demo\include\dotnettabctrl.h(1511) : see reference to class template instantiation 'CDotNetButtonTabCtrl<TItem>' being compiled
C:\samples\splitpane_demo\include\dotnettabctrl.h(1515) : error C3203: 'CDotNetTabCtrl' : unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type
            C:\samples\splitpane_demo\include\dotnettabctrl.h(1535) : see reference to class template instantiation 'CDotNetTabCtrl<TItem>' being compiled
C:\samples\splitpane_demo\splitpanedemo\mainfrm.h(30) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\samples\splitpane_demo\splitpanedemo\mainfrm.h(31) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Generating Code...
Build log was saved at "file://C:\samples\splitpane_demo\SplitPaneDemo\Debug\BuildLog.htm"
SplitPaneDemo - 22 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

AnswerRe: it breaks in VC++ 8memberfermil2 Jul '07 - 5:16 
Try using the atlgdix.h coming from Daniel Bowen article. It removes all the class definitions causing errors. It worked for me in VC7 (.NET 2003). If not, probably you need to adjust the stdafx.h as well, as I did. Let me know.
GeneralProblem with the codememberdkrsaturndev22 Nov '05 - 8:23 
I downloaded the Demo and the Code but the link to the latest code version doesn't work. When I try to build the project I get error messages about missing Header files. Any thoughts?
 
Thanks - Jeff
GeneralError building projectmemberPaulaPaziani20 Oct '05 - 6:54 
I´m trying to build your project, but the Visual Studio .NT 2003 doesn´t get to find some atl, like atlddx.h and others that are not in Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include.
Where can I find these includes?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 7 Jan 2004
Article Copyright 2004 by Igor Katrayev
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid