It adds the ability to dock and float windows at the edges of the
WTL application.
Please note that it is not a Control Bar implementation, so: you
cannot dock in the toolbar area; you're not allowed to bundle several
docking areas side by side; it has very simplistic sizing algorithms;
it's difficult to restore the exact docking position programmatically.
But still, it smells like docking windows.
It's easy to add the docking framework to your project. Assuming
it's a MDI project (though it works with SDI projects too) you
need to add the atldock.h header to your includes.
Then add a docking window to your frame window:
CDockingWindow m_dock;
Create the docking window after the MDI client has been
created and set, like this:
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM ...
{
...
CreateMDIClient();
m_CmdBar.SetMDIClient(m_hWndMDIClient);
m_hWndClient = m_dock.Create(m_hWnd, rcDefault);
m_dock.SetClient(m_hWndMDIClient);
...
Then create the views and add them to the docking framework
using the AddWindow()
method. Use the
DockWindow()
method to place the window in its
initial docking position.
m_view1.Create(m_hWndClient, rcDefault, _T("View1"),
WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|
WS_CLIPCHILDREN,
WS_EX_CLIENTEDGE);
m_dock.AddWindow(m_view1);
m_dock.DockWindow(m_view1, DOCK_LEFT);
And that's it.
You may want to hook up the views and the MDI client for window messaging too. There are several options (like using the
PreTranslateMessage()
method) but you
might as well use the message map macros:
CHAIN_MDI_CHILD_COMMANDS()
CHAIN_DOCK_CHILD_COMMANDS(m_view1)
The docking class supports a few optional settings, which controls how windows are managed when they are closed. Much of this support was added by Mike Simon. Use the
SetExtendedDockStyle
to control the behaviour.
Other Extensions
Also included in the package are classes for an alternate framework look. They are based on modifications Jens Nilsson sent me. They demonstrate how to override the custom painting of splitter bars and grippers.To use them, include atldock2.h and use
CFlatDockingWindow
instead of
CDockingWindow
.
Jens Nilsson also contributed with a "stacking" version, which behaves a bit like the VISIO stencil user interface. You can download it here.
Source Code Dependencies
Microsoft WTL 3.1 LibrarySee Also
A WTL sample that uses the classDownload Files
![]() | Source Code (15 Kb) |