views:

10

answers:

0

For various reasons, I have to reimplement MFC's print preview functionality. I'd like to re-use its styled print preview dialog bar in a CFrameWndEx, but I've been running into problems.

First, if I use something like the following in a CFrameWnd, I can successfully embed the toolbar:

if (!m_wndDlgBar.Create(this, ATL_MAKEINTRESOURCE(AFX_IDD_PREVIEW_TOOLBAR), CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY, AFX_IDW_PREVIEW_BAR))
{
    TRACE0("DlgBar init failed");
    return -1;
}

EnableDocking(CBRS_ALIGN_TOP);
m_wndDlgBar.EnableDocking(CBRS_ALIGN_TOP);
DockControlBar(&m_wndDlgBar);

However, this code results in an assertion failure with CFrameWndEx. Acting on the advice of this thread, I replaced the calls to EnableDocking and DockControlBar with direct calls to CFrameWnd's implementation, and overrode RecalcLayout as well to call into CFrameWnd directly, but the bar still did not show.

How can I get this print preview bar to appear in a CFrameWndEx? Alternately, is there a way to get a CFrameWnd to participate in the CMFCVisualManager system?