![]() |
Platforms, Frameworks & Libraries »
WTL »
General
Intermediate
WTL Docking WindowsBy Sergey KlimovThis is an implementation of docking windows for the WTL library |
VC6, VC7Win2K, WinXP, WTL, STL, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

This is an implementation of docking windows for the WTL library. The following topics describe how to use docking window classes.
DockImpl.cpp to the project. Probably the best way to do it is to add #include<DockImpl.cpp> to the stdafx.cpp. /GX or /EH compiler options) and remove _ATL_MIN_CRT from the list the preprocessor defines in release configuration. If you use standard HP's STL you can leave default project setting intact, but I don't think it is a good idea. USE_BOOST. WM_USER to WM_USER + 2WMDF_FIRST = WM_USERWMDF_LAST = WM_USER + 2WMDF_LAST+1 or if it is impossible redefine WMDF_FIRST. #include <DockingFrame.h> to CMainFrame header. CMainFrame class to dockwins::CDockingFrameImpl<CMainFrame> for SDI applications or to dockwins::CMDIDockingFrameImpl<CMainFrame> for MDI applications. All references to previous base class should be replaced by new one. OnCreate method of your CMainFrame class InitializeDockingFrame(); it's the best place to change windows behavior of docking window. By default it is depend on system setting (Show window contents while dragging) if you for some reason need to change it you should use the following flags:CDockingBarStyle::sUseSysSettings � depend on system setting, default.CDockingBarStyle::sIgnoreSysSettings | CDockingBarStyle::sFullDrag � full dragCDockingBarStyle::sIgnoreSysSettings | CDockingBarStyle::sGhostDrag � ghost drag.CDockingBarStyle::sAnimation � animate auto-hiding windows.CDockingBarStyle::sNoAnimation � do not animate auto-hiding windows. #include <ExtDockingWindow.h> to header file of your docking window. CSampleDockingWindow for example. Derive it from dockwins::CTitleDockingWindowImpl. DECLARE_WND_CLASS macro The CSampleDockingWindow class should look like this:
class CSampleDockingWindow :
public dockwins::CTitleDockingWindowImpl< SampleDockingWindow,
CWindow, dockwins::COutlookLikeTitleDockingWindowTraits >
{
typedef CSampleDockingWindow thisClass;
typedef dockwins::CTitleDockingWindowImpl<CSAMPLEDOCKINGWINDOW,
CWINDOW,
dockwins::COutlookLikeTitleDockingWindowTraits> baseClass;
public:
DECLARE_WND_CLASS(_T("CSampleDockingWindow"))
BEGIN_MSG_MAP(thisClass)
CHAIN_MSG_MAP(baseClass)
END_MSG_MAP()
};
CSampleDockingWindow class as a member of the CMainFrame CMainFrame::OnCreate(...) method, call the Create(...) method of the instantiated docking window class.
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,
BOOL& /*bHandled*/)
{
...
InitializeDockingFrame();
...
CRect rcBar(0,0,100,100);
m_sampleDockWnd.Create(m_hWnd,rcBar,_T("Sample docking window"));
...
}
Do not use empty rect even if you dock the window. When window start dragging it use previously stored floating rect size.
To implement a window with docking window features, derive a class from dockwins::CDockingSiteImpl. In derived class chain default message map to the base class.
class CDockSiteSampleWnd : public dockwins::CDockingSiteImpl <
CDockSiteSampleWnd >
{
typedef dockwins::CDockingSiteImpl < CDockSiteSampleWnd > baseClass;
public:
DECLARE_WND_CLASS(_T("CDockSiteSampleWnd"))
BEGIN_MSG_MAP(CDockSiteSampleWnd)
CHAIN_MSG_MAP(baseClass)
END_MSG_MAP()
};
dockwins::CTitleDockingWindowImpl to dockwins::CBoxedDockingWindowImpl. dockwins::CBoxedDockingWindowImpl: COutlookLikeBoxedDockingWindowTraits, COutlookLikeExBoxedDockingWindowTraits or CVC6LikeBoxedDockingWindowTraits. CSampleDockingWindow class, the code should look like this:
class CSampleTabDockingWindow :
public dockwins::CBoxedDockingWindowImpl< SampleDockingWindow,
CWindow, dockwins::COutlookLikeBoxedDockingWindowTraits >
{
typedef CSampleTabDockingWindow thisClass;
typedef dockwins::CBoxedDockingWindowImpl<CSAMPLEDOCKINGWINDOW,
CWINDOW,
dockwins::COutlookLikeBoxedDockingWindowTraits> baseClass;
public:
DECLARE_WND_CLASS(_T("CSampleTabDockingWindow"))
BEGIN_MSG_MAP(thisClass)
CHAIN_MSG_MAP(baseClass)
END_MSG_MAP()
};
To add auto-hiding features to your project just include a DWAutoHide.h header before any other docking windows headers.
Call the DockWindow methods from your frame window class.
template<class T>
bool DockWindow(T& dockWnd,CDockingSide side,
unsigned long nBar,float fPctPos,
unsigned long nWidth, unsigned long nHeight);
CDockingSide::sSingle force docking window to occupy the fulll width of the docking bar, combine this style with one of the following:CDockingSide::sRight Dock to the right side of the frame window.CDockingSide::sLeft Dock to the left side of the frame window.CDockingSide::sTop Dock to the top side of the frame window.CDockingSide::sBottom Dock to the bottom side of the frame window. Call the DockTo method of the tabbed docking window.
bool DockTo(HWND hWnd,int index=0);
Call the Float methods from your docking window class.
bool Float() - restore previous floating positionbool Float(LPCRECT pRc,
UINT flags=SWP_SHOWWINDOW | SWP_NOACTIVATE,
HWND hWndInsertAfter=HWND_TOP) - float docking window and move to a specified location. Call the one of the PinUp methods of the tabbed docking window.
bool PinUp(const CDockingSide& side);
bool PinUp(const CDockingSide& side, unsigned long width,
bool bVisualize=false);
CDockingSide::sRight Pin-up to the right side of the frame window.CDockingSide::sLeft Pin-up to the left side of the frame window.CDockingSide::sTop Pin-up to the top side of the frame window.CDockingSide::sBottom Pin-up to the bottom side of the frame window. Call Hide then Show methods of the pinned window to emulate the pin button press,
or call Float method to float a pinned docking window,
or call Hide method then call any functions that set docking window position.
Override the following member functions of your docking window class
void OnDocked(HDOCKBAR hBar,bool bHorizontal) void OnUndocked(HDOCKBAR hBar)
To hide/show a docking window simply call Hide()/ Show() or Togle() methods of the CTitleDockingWindowImpl class.
You can specify minimum docking window size by overriding GetMinMaxInfo method of your docking window, like this:
void GetMinMaxInfo(LPMINMAXINFO pMinMaxInfo) const
{
pMinMaxInfo->ptMinTrackSize.y=100;
pMinMaxInfo->ptMinTrackSize.x=100;
}
You can use following member functions of the CDockingWindowBaseImpl class:
bool GetDockingWindowPlacement(DFDOCKPOSEX* pHdr) constbool SetDockingWindowPlacement(DFDOCKPOSEX* pHdr) If you do not like splitter bar you can make your own. If you just want to change it's appearance probably the best way to derive it from CSimpleSplitterBar. And override Draw(),DrawGhostBar() etc. Then define your traits
typedef CDockingFrameTraitsT <CMySplitterBar,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE> CMyDockingFrameTraits;
and apply it to base class of CMainFrame.
Create a new caption class. You can derive it from CCaptionBase or from other available Caption classes. Then define DockingWindowTraits
typedef CDockingWindowTraits<CMyCaption,
WS_OVERLAPPEDWINDOW | WS_POPUP | WS_VISIBLE |
WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
WS_EX_TOOLWINDOW> CMyTitleDockingWindowTraits;
and apply it to CTitleDockingWindowImpl.
CDockingFrameImplBase[DockingFrame.h] � this class provides basic docking window features. CDockingFrameImpl [DockingFrame.h] � base class for a single document interface (SDI) frame window. CMDIDockingFrameImpl [DockingFrame.h] � base class for a multiple document interface (MDI) frame window. CDockingSiteImpl [DockingFrame.h] � base class for a generic window with docking window features. CDockingFrameTraitsT [DockMisc.h] � traits of docking frame it's derived from CWinTraits class and add TSplitterBar parameter. CDockingWindowBaseImpl [DockingWindow.h] � base class for docking windows. The CDockingWindowBaseImpl class derives from CWindowImpl and has the same parameters except TWinTraits. Instead, it is uses CDockingWindowTraits. CTitleDockingWindowImpl [DockingWindow.h] � titled docking window. CBoxedDockingWindowImpl [DockingBox.h] � titled docking window which support tabbed docking. CDockingWindowTraits [DockingWindow.h] � traits of docking window it's derived from CWinTraits class and add TCaption parameter. If you need to customize the docking window caption, make new caption class and use CDockingWindowTraits with new class as TCaption parameter. CCaptionBase[DockingWindow.h] � base class for other caption class COutlookLikeExCaption and COutlookLikeCaption [ExtDockingWindow.h] � Microsoft Outlook� likes caption. COutlookLikeCaption � always horizontal caption. COutlookLikeExCaption � orientation of the caption depends on docking position. CVC6LikeCaption [ExtDockingWindow.h] � Microsoft Visual C++ 6� IDE like caption. COutlookLikeTitleDockingWindowTraits [ExtDockingWindow.h] traits for COutlookLikeCaption, use this class with CTitleDockingWindowImpl COutlookLikeExTitleDockingWindowTraits [ExtDockingWindow.h] traits for COutlookLikeExCaption, use this class with CTitleDockingWindowImpl CVC6LikeTitleDockingWindowTraits [ExtDockingWindow.h] traits forCVC6LikeCaption, use this class with CTitleDockingWindowImpl COutlookLikeBoxedDockingWindowTraits [TabDockingBox.h] traits for COutlookLikeCaption, use this class with CBoxedDockingWindowImpl COutlookLikeExBoxedDockingWindowTraits [TabDockingBox.h] traits for COutlookLikeExCaption, use this class with CBoxedDockingWindowImpl CVC6LikeBoxedDockingWindowTraits[TabDockingBox.h] traits for CVC6LikeCaption, use this class with CBoxedDockingWindowImpl CSimpleSplitterBar[SimpleSplitterBar.h] - Very simple splitter bar. CSimpleSplitterBarEx[SimpleSplitterBar.h] - another simple splitter bar.
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 21 Nov 2007 Editor: Sean Ewington |
Copyright 2002 by Sergey Klimov Everything else Copyright © CodeProject, 1999-2009 Web22 | Advertise on the Code Project |