Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Docking Pane
  New Posts New Posts RSS Feed - Creating multiple CFormView based Panes
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Creating multiple CFormView based Panes

 Post Reply Post Reply
Author
Message
turbowagon View Drop Down
Newbie
Newbie


Joined: 28 June 2005
Location: United States
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote turbowagon Quote  Post ReplyReply Direct Link To This Post Topic: Creating multiple CFormView based Panes
    Posted: 27 July 2005 at 10:06am

I was stuck on this for a little while, so I thought I'd share my solution.  All of the examples using a CFormView to create a Dialog-based docking pane only made use of a single view class.  I make use of the Docking Pane ID to handle each pane's creation:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
 ...

 // Create docking panes.
 CXTPDockingPane* pPaneProperties = m_paneManager.CreatePane(
  PANEID_FORMVIEW, CRect(0, 0,210, 120), xtpPaneDockLeft);

 CXTPDockingPane* pPaneSecond = m_paneManager.CreatePane(
  PANEID_SECONDFORM, CRect(0, 0, 210, 120), xtpPaneDockRight);

 return 0;
}

Then in the OnDockingPaneNotify message handler, you can use a switch statement to conditionally create the appropriate panes:

LRESULT CMainFrame::OnDockingPaneNotify(WPARAM wParam, LPARAM lParam)
{
 if (wParam == XTP_DPN_SHOWWINDOW)
 {
  CXTPDockingPane* pPane = (CXTPDockingPane*)lParam;

  if (!pPane->IsValid())
  {
   switch(pPane->GetID())
   {
   case PANEID_FORMVIEW:

    if (m_pFormFrame == NULL)
    {
     m_pFormFrame = new CFrameWnd;
    
     CCreateContext context;
     context.m_pNewViewClass = RUNTIME_CLASS(CSimpleFormView);
     context.m_pCurrentDoc = NULL;
    
     m_pFormFrame->Create(NULL, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, CRect(0, 0, 0, 0), this, NULL, 0, &context);
     m_pFormFrame->ModifyStyleEx (WS_EX_CLIENTEDGE, 0);
     m_pFormFrame->SendMessageTo Descendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE);
    }

    pPane->Attach(m_pFormFrame);
    break;

   case PANEID_SECONDFORM:

    if (m_pSecondFrame == NULL)
    {
     m_pSecondFrame = new CFrameWnd;

     CCreateContext context;
     context.m_pNewViewClass = RUNTIME_CLASS(CSecondFormView);
     context.m_pCurrentDoc = NULL;
    
     m_pSecondFrame->Create(NULL , NULL, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, CRect(0, 0, 0, 0), this, NULL, 0, &context);
     m_pSecondFrame->ModifyStyle Ex(WS_EX_CLIENTEDGE, 0);
     m_pSecondFrame->SendMessage ToDescendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE);
    }

    pPane->Attach(m_pSecondFrame);
    break;

   default:
    AfxMessageBox("Unknown pane ID");
    return FALSE;
   }
  }
 
  return TRUE; // handled
 }

 return FALSE;
}



Edited by turbowagon
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.