views:

716

answers:

3

Hello, I have problem with CPaneDialog. I tested with SetPaneSize MFC feature pack sample projects. What is weird is that CPaneDialog can't be docked to MainFrm while CDockablePane can be. The CPaneDialog is also a child class of the CDockablePane, but it can't be. Only DockToWindow( &other_CPaneDialog_instance... ) is possible. If I call DockToPane(), the content of the CPaneDialog is not drawn or refreshed correctly.

How can a CPaneDialog be docked to MainFrm window?

Another problem is about drawing. If remove codes for tree control in the SetPaneSize sample, the content of the view1 ( an instance of CDockablePane) is not redrawn properly. After doing some experiment, I decided that something should be done in its OnSize and OnPaint method. (OnSize is more critical. ) Is this expected behaviour?

+1  A: 

While converting an older MFC-application I ran into similar problems with the feature pack. I didn't have the time to solve it correctly, but I used following workaround:

  1. take your dialog resource and put it in a CDialogBar class.
  2. now derive a class from CDockablePane
  3. in the OnCreate-method of the pane, create your dialogbar.

2 more things:

void CInputPane::OnSize(UINT nType, int cx, int cy)
{
    CDockablePane::OnSize(nType, cx, cy);
    m_pInputBar->SetWindowPos(NULL,0,0,cx,cy,SWP_NOACTIVATE | SWP_NOZORDER);
}

BOOL CInputPane::OnBeforeFloat(CRect& /*rectFloat*/,AFX_DOCK_METHOD /*dockMethod*/)
{
    return FALSE;
}

This assures proper sizing of the dialog and preventing the user from dragging the bar around.

HTH, it worked for me.

dwo
Thank you. Actually I saw similar solution somewhere else, but wouldn't CPaneDialog is for this kind of purpose? Also, unlike other CDockablePane derivatives, CPaneDialog behaves weirdly in that it can't be docked using DockPane().
JongAm Park
A: 

Converting HexEdit to MFC9 (see http://www.hexedit.com) I ran into this problem. I tested in VS2010 (MFC10) and this bug appears to have been fixed.

Also note that this problem is not a major thing as you can just use DockToWindow in CMainFrame::OnCreate to dock to a CDockablePane (if you have one). The user can float the window or dock it elsewhere and the position will be remembered and restored when the program is re-opened.

I am pretty sure someone new about this bug in MFC9 - hence the obvious workaround in the SetPaneSize demo (calling CDockablePane::DockToWindow rather than DockPane as was used for all the other dockable windows). But at least it is fixed in MFC10.

Another bug I found is that if a CPaneDialog is floating when closed (hidden), then when you restart the application the pane is reopened, rather than being restored in the correct (hidden) state. This does not occur if the pane is docked when closed. This has also been fixed in MFC10.

Andrew
Thank you for the additional information
JongAm Park
A: 

Thank you for the additional information, Andrew

JongAm Park