dockingframework.cpp

来自「These listed libraries are written in WT」· C++ 代码 · 共 91 行

CPP
91
字号
#include "stdafx.h"
#include "DockingFramework.h"

namespace WTL
{
#include "Docking\dockimpl.cpp"
}

CComModule _Module;

IMPLEMENT_DYNAMIC(CDockingFrameWnd, CFrameWnd)
IMPLEMENT_DYNAMIC(CDockingMDIFrameWnd, CMDIFrameWnd)
IMPLEMENT_DYNAMIC(CDockingControlBar, CWnd)

BEGIN_MESSAGE_MAP(CDockingControlBar, CWnd)
	ON_WM_SIZE()
	ON_WM_SETFOCUS()
	ON_WM_NCCREATE()
END_MESSAGE_MAP()

CDockingControlBar::CDockingControlBar()
: m_pWndParentFrame(NULL)
{
}

// virtual
BOOL CDockingControlBar::PreCreateWindow(CREATESTRUCT& cs)
{
	// Workaround to avoid MFC assertion
	cs.style |= WS_CHILDWINDOW;
	BOOL blResult = __super::PreCreateWindow(cs);

	cs.style &= ~WS_CHILDWINDOW;
	cs.style |= (WS_OVERLAPPEDWINDOW | WS_POPUP);
	cs.dwExStyle |= WS_EX_TOOLWINDOW;

	// A control bar never has a menu
	ASSERT(FALSE == IsMenu(cs.hMenu));
	m_wndWTLPeer.m_nCtrlID = (UINT) cs.hMenu;
	cs.hMenu = NULL;

	return blResult;
}

BOOL CDockingControlBar::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
{
	// Keep the parent for later use
	CWnd* pParent = CWnd::FromHandlePermanent(lpCreateStruct->hwndParent);
	if(pParent->IsKindOf(RUNTIME_CLASS(CDockingMDIFrameWnd)))
	{
		m_pWndParentFrame = & static_cast<CDockingMDIFrameWnd*>(pParent)->m_wndWTLPeer;
	}
	else
	{
		ASSERT_KINDOF(CDockingFrameWnd, pParent);
		m_pWndParentFrame = & static_cast<CDockingFrameWnd*>(pParent)->m_wndWTLPeer;
	}

	// mimic CDockingWindowBaseImpl::Create
	m_wndWTLPeer.m_docker = WTLClass::CDocker(lpCreateStruct->hwndParent);

	// add this control bar to the list
	m_pWndParentFrame->AddControlBar(&this->m_wndWTLPeer);

	return __super::OnNcCreate(lpCreateStruct);
}

// virtual
void CDockingControlBar::PostNcDestroy()
{
	m_pWndParentFrame->RemoveControlBar(&this->m_wndWTLPeer);
	__super::PostNcDestroy();
}

void CDockingControlBar::OnSize(UINT nType, int cx, int cy)
{
	if(SIZE_MINIMIZED != nType)
	{
		RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST);
	}
}

void CDockingControlBar::OnSetFocus(CWnd* pOldWnd)
{
	HWND hWndChild = ::GetDlgItem(m_hWnd, AFX_IDW_PANE_FIRST);
	if(NULL != hWndChild)
	{
		::SetFocus(hWndChild);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?