CDockablePane doesn't save layout when it's docked to another pane

819 views Asked by At

In an MFC application, I've got two derived CDockablePane pane objects docked to either side of the main view.

Here is the code to create one of the panes. The second is similar.

if(m_dlgPane && m_dlgPane->GetSafeHwnd())
{
    m_dlgPane->ShowPane(TRUE,FALSE,TRUE);
    //RecalcLayout();
    return ;
}
m_dlgPane = new CDialogPane; 
((CDialogPane*)m_dlgPane)->m_wndDlg = new CPaneChildDlg();
((CDialogPane*)m_dlgPane)->nDlgID = CPaneChildDlg::IDD;

UINT style = WS_CHILD | CBRS_RIGHT | CBRS_FLOAT_MULTI;
CString strTitle = _T("Child Dialog Pane");
if (!m_dlgPane->Create(strTitle, this, CRect(0, 0, 300, 400), TRUE,
    IDC_DIALOG_PANE, style,AFX_CBRS_OUTLOOK_TABS))
{
    TRACE0("Failed to create dialog pane\n");
    SAFE_DELETE(m_dlgPane);
    return ; 
}
m_dlgPane->EnableDocking(CBRS_ALIGN_ANY);
DockPane((CBasePane*)m_dlgPane,AFX_IDW_DOCKBAR_RIGHT);

m_dlgPane->ShowPane(TRUE, FALSE, TRUE);
m_dlgPane->RecalcLayout();

The layouts are saved by windows through LoadState & SaveState methods. And are called by the framework.

BOOL CDialogPane::SaveState(LPCTSTR lpszProfileName, int nIndex, UINT uiID)
{
    return CDockablePane::SaveState(lpszProfileName, nIndex, uiID);
}

BOOL CDialogPane::LoadState(LPCTSTR lpszProfileName, int nIndex, UINT uiID)
{
    return CDockablePane::LoadState(lpszProfileName, nIndex, uiID); 
}

The layouts loaded properly each time application launches. Apart from when one pane(Pane2) is docked to the other one(Pane1). It seems that it doesn't remember or load the correct height of the Pane2. Although this works throughout the application lifetime but not when the application exists and opens again.

0

There are 0 answers