Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 328981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:32:44+00:00 2026-05-12T09:32:44+00:00

In my MFC (Feature Pack) application one can dynamically create docking panes to display

  • 0

In my MFC (Feature Pack) application one can dynamically create docking panes to display charts/tables etc.
However, I don’t want to let the user open the same thing twice.

I create a pane like this:

// Create CMyDockablePane pPane
pPane->Create(...);
pPane->EnableDocking(CBRS_ALIGN_ANY);
// Create CRect rcPane
pPane->FloatPane(rcPane);

This seems to work fine.

This is how I tried to check if a pane already exists. A pane is identified by its type (class) and a parameter.

BOOL CanOpenPane(const type_info & paneType, const CMyParameter & parameter) const
{
    CMainFrame* pFrm = GetMainFrame();
    CDockingManager* pDockMan = pFrm->GetDockingManager();


    // Check if there already is a pane of the same type which also has the same parameter.
    bool canOpen = true;
    CObList panes;
    pDockMan->GetPaneList(panes);
    POSITION pos = panes.GetHeadPosition();
    while (pos)
    {
        CMyDockablePane* pPane = dynamic_cast<CMyDockablePane*>(panes.GetNext(pos));
        if (NULL == pPane) { continue; }

        if (paneType == typeid(*pPane) &&
                pPane->GetParameter() == parameter)
        {
            canOpen = false;
            break;
        }
    }


    return canOpen;
}

The problem with this is that when I close a pane, this is not recognized. The CDockingManager object still returns the pane in the GetPanes() call.

How can I tell the manager to not return panes that are closed?
or
How can I remove the pane from a pane list, when it’s closed?


Update

I dived a bit deeper and found, that the CWnd objects are not actually closed, when clicking the ‘x’ button in the caption bar, but only their containers.
So the real problem seems to be to really close the panes.
I also changed the question to better reflect the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:32:45+00:00Added an answer on May 12, 2026 at 9:32 am

    As described in my update, the problem for the docking manager giving me closed panes, was that the panes were not actually closed. Only their containers were closed; the panes themselves were just hidden.

    So to really close the panes I overrode the following methods in my CMDIFrameWndEx derived main frame class:

    BOOL CMainFrame::OnCloseMiniFrame(CPaneFrameWnd* pWnd)
    {
        if(0 == pWnd->GetPaneCount()) { return TRUE; } // No panes.. allow closing
    
        // Close all child panes of the miniframe that is about to be closed.
        //
        // Panes are placed inside a mini frame when they have the "floating" status.
        // Since I didn't find a way to iterate over the panes of a mini frame
        // (CMultiPaneFrameWnd can have several panes), we iterate over all panes
        // and close those whose parent frame is pWnd.
    
        CDockingManager* pDockMan = GetDockingManager();
        if(NULL != pDockMan)
        {
            CObList allPanes;
            pDockMan->GetPaneList(allPanes, TRUE, NULL, TRUE);
    
            for(POSITION pos = allPanes.GetHeadPosition(); pos != NULL;)
            {
                CDockablePane* pPane = dynamic_cast<CDockablePane*>(allPanes.GetNext(pos));
                if (NULL == pPane) { continue; }
    
                if(pWnd == pPane->GetParentMiniFrame())
                {
                    pPane->PostMessage(WM_CLOSE); // Note: Post instead of Send
                }
            }
    
        }
    
        return TRUE; // Allow closing
    }
    

    And the second:

    BOOL CMainFrame::OnCloseDockingPane(CDockablePane* pWnd)
    {
        CObList paneList;
    
        // We can get CDockablePanes and CTabbedPanes here.
        // The tabbed panes contain dockable panes.
        CTabbedPane* pTabbed = dynamic_cast<CTabbedPane*>(pWnd);
        CDockablePane* pDockable = dynamic_cast<CDockablePane*>(pWnd);
        if(NULL != pTabbed)
        {
            pTabbed->GetPaneList(paneList);
        }
        else if(NULL != pDockable)
        {
            paneList.InsertAfter(paneList.GetHeadPosition(), pDockable);
        }
    
        // Whatever it was, we now have a list of dockable panes, which we will close.
        for(POSITION pos = paneList.GetHeadPosition(); NULL != pos;)
        {
            CDockablePane* pPane = dynamic_cast<CDockablePane*>(paneList.GetNext(pos));
            ASSERT(NULL != pPane);
    
    
            // Let the window disappear and then recalculate the layout.
            // Not doing this causes problems with panes grouped together in a tabbed pane.
            pPane->ShowWindow(SW_HIDE);
            RecalcLayout();
    
            // Really close the window so the docking manager also doesn't know of it anymore.
            pPane->Reset();
            pPane->PostMessage(WM_CLOSE); // Note: Post instead of Send
        }
    
    
        return TRUE; // Allow closing
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are a couple of variants of a rename command,… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer There is currently no way to build CLS-compliant assemblies from… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer You might want to look at Google Protocol Buffers or… May 12, 2026 at 12:33 pm

Related Questions

I want to display a map in a MFC application (Visual Studo 2008 with
I am trying to use some classes from the MFC Feature Pack to improve
Imagine I want to create an application which is very similar to MS Word
My company has developed a long standing product using MFC in Visual C++ as
In trying to get up to speed with C++ (coming from a long experience

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.