CDialogに領域を作成して、CDockablePanesを配置できるようにします。これらは、固定のダイアログコンテンツに完全にドッキングできます。
Codejock Dialog Panes Sampleはまさに私が望むものですが、MFC機能パッククラスで実現されています:http://codejock.com/downloads/samples/dockingpane.asp
現時点では、CDialogに埋め込まれているCFrameWndExから継承されたクラスを取得しました。また、動作するCDockablePaneも含まれています。ドッキングを解除して移動できますが、ドッキングしたいときにプログラムがクラッシュします。
これは、ドッキング可能なペインクラスが、実際のペインの移動先をプレビューするためのダミーペインを生成しようとするためです。NULLを返すGetTopLevelFrame()を呼び出します。これにより、afxpane.cpp @CreateEx()でクラッシュが発生します。
誰かが私のために何か助けやアイデアを持っていますか?:(
挨拶、
編集:
わかりました、いくつかのコード:
CFrameWndExから継承された小さなクラスを作成しました(コンストラクターが保護されているため):
class CMyFrame: public CFrameWndEx
{
public:
DECLARE_MESSAGE_MAP()
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
CDockablePane m_DockWnd; // Will use an own class inherited from CDockablePane later on
};
次に、このクラスをCDialogに埋め込み、そのサイズをダイアログサイズに変更します。
BOOL CMyDlg::OnInitDialog()
{
CRect wndRect;
GetWindowRect(wndRect);
m_pFrame = new CMyFrame();
m_pFrame->Create(NULL, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, wndRect, this);
m_pFrame->MoveWindow(wndRect);
CDialog::OnInitDialog();
...
}
CMyFrameクラスのOnCreate()で、CDockablePaneを設定してドッキングします。
int CMyFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
return -1;
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
EnableDocking(CBRS_ALIGN_ANY);
// DT_SMART creates dummy dockable panes for previewing the possible position of
// the currently floating pane, this leads to a crash at call to GetTopLevelFrame()
CDockingManager::SetDockingMode(DT_SMART);
EnableAutoHidePanes(CBRS_ALIGN_ANY);
// m_DockWnd is a CDockablePane
if (!m_DockWnd.Create(_T("Test"), this, CRect(0, 0, 200, 200), TRUE, IDC_DOCK_WND,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create Properties window\n");
return 1; // failed to create
}
m_DockWnd.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_DockWnd);
return 0;
}