This article was submitted .

This is an implementation of a basic docking windows framework for the WTL library.

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 ...

      m_hWndClient = m_dock.Create(m_hWnd, rcDefault);
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"), 
      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:

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 Library

See Also

A WTL sample that uses the class

Download Files

DownloadSource Code (15 Kb)

To the top