views:

257

answers:

0

Hi,

I have created dockable panes in my CChildFrame class in OnCreate() :

int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIChildWndEx::OnCreate(lpCreateStruct) == -1) return -1;

// TODO:  Add your specialized creation code here

/* m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_CHILDFRAME); m_wndToolBar.LoadToolBar(IDR_CHILDFRAME, 0, 0, TRUE ); m_wndToolBar.SetPaneStyle( CBRS_TOOLTIPS | CBRS_FLYBY| CBRS_BOTTOM); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndToolBar); */
CDockingManager::SetDockingMode(DT_SMART);

EnableAutoHidePanes(CBRS_ALIGN_ANY);

BOOL bNameValid;
CString strClassView;
CString strFileView;

bNameValid = strClassView.LoadString(IDS_CLASS_VIEW);
ASSERT(bNameValid);
if (!m_wndClassView2.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{
    TRACE0("Failed to create Class View window\n");
    return FALSE; // failed to create
}

// Create file view
bNameValid = strFileView.LoadString(IDS_FILE_VIEW);
ASSERT(bNameValid);
if (!m_wndFileView2.Create(strFileView, this, CRect(500, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM| CBRS_FLOAT_MULTI))
{
    TRACE0("Failed to create File View window\n");
    return FALSE; // failed to create
}

m_wndFileView2.EnableDocking(CBRS_ALIGN_ANY);
m_wndClassView2.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndFileView2);
CDockablePane* pTabbedBar2 = NULL;
m_wndClassView2.AttachToTabWnd(&m_wndFileView2, DM_SHOW, TRUE, &pTabbedBar2);


bNameValid = strClassView.LoadString(IDS_CLASS_VIEW);
ASSERT(bNameValid);
if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI))
{
    TRACE0("Failed to create Class View window\n");
    return FALSE; // failed to create
}

// Create file view
bNameValid = strFileView.LoadString(IDS_FILE_VIEW);
ASSERT(bNameValid);
if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT| CBRS_FLOAT_MULTI))
{
    TRACE0("Failed to create File View window\n");
    return FALSE; // failed to create
}

m_wndFileView.EnableDocking(CBRS_ALIGN_ANY);
m_wndClassView.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndFileView);
CDockablePane* pTabbedBar = NULL;
m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar);

HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(/*bHiColorIcons ? IDI_FILE_VIEW_HC : */IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0);
m_wndFileView.SetIcon(hFileViewIcon, FALSE);
m_wndFileView2.SetIcon(hFileViewIcon, FALSE);

HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(/*bHiColorIcons ? IDI_CLASS_VIEW_HC : */IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0);
m_wndClassView.SetIcon(hClassViewIcon, FALSE);
m_wndClassView2.SetIcon(hClassViewIcon, FALSE);



return 0;

}

If i drag the m_wndFileView and/or m_wndFileView2 (CDockablePane) windows they disappear from my CChildFrame window. (I click THE TAB of the m_wndFileView window and drag the window out.) The m_wndClassView and m_wndClassView2 (CDockablePane) windows dont disappear when dragged. There are also similar dockable windows attached to CMainFrame, here they dont disappear when dragged and i can re-dock them where i want. I created those CChildFrame dockable windows exactly from the code used in CMainFrame::CreateDockingWindows()

Why does this go wrong for a dockable window attached to CChildFrame and not for a CMainFrame attached dockable window ?

my simple project is here to demonstrate : http://www.4shared.com/file/238494218/4ad41b3f/GUI60.html