Print Page | Close Window

Creating multiple CFormView based Panes

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Docking Pane
Forum Description: Topics Related to Codejock Docking Pane
URL: http://forum.codejock.com/forum_posts.asp?TID=2645
Printed Date: 04 May 2024 at 11:27am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Creating multiple CFormView based Panes
Posted By: turbowagon
Subject: Creating multiple CFormView based Panes
Date 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;
}




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net