-
StackOverflow 文档
-
mfc 教程
-
可停靠控制杆(窗格)
-
将窗格停靠在框架的左侧
// Main frame class declaration
class CMainFrame
: public CMDIFrameWndEx
{
DECLARE_DYNAMIC(CMainFrame)
protected:
// declare our pane
CDockablePane m_wndPane;
// .... other class memebers
public:
CMainFrame();
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
DECLARE_MESSAGE_MAP()
};
// Main frame class implementation
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx)
ON_WM_CREATE()
END_MESSAGE_MAP()
CMainFrame::CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
return -1;
// enable frame docking to any sides
EnableDocking(CBRS_ALIGN_ANY);
// set the visual manager used to draw all user interface elements
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
// enable smart docking style window behavior
CDockingManager::SetDockingMode(DT_SMART);
// Other frame initialization code
// ....
// Creating the pane.
// ID_VIEW_PANE_ID - pane ID, must be declared in resource.h
// CRect(0, 0, 100, 100) - default pane size in floating state (pane is not docked to any frame sides).
// CBRS_LEFT - default side for pane docking.
if (!m_wndPane.Create(_T("My Pane"), this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_PANE_ID, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) {
TRACE0("Failed to create Pane\n");
return -1; // failed to create
}
// Enable docking and redocking pane to frame any sides (you can pass a combination of CBRS_ALIGN_ flags)
m_wndPane.EnableDocking(CBRS_ALIGN_ANY);
// Dock pane to the default (left) side of the frame.
DockPane(&m_wndPane);
return 0;
}