Print Page | Close Window

How to access control on Pane1 from Pane2

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=921
Printed Date: 10 May 2024 at 3:43am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to access control on Pane1 from Pane2
Posted By: AdrianM
Subject: How to access control on Pane1 from Pane2
Date Posted: 06 July 2004 at 7:42pm

I'm trying to access tree control data on inactive Pane2, from active Pane1.  Both are CFormView panes in an SDI app.  Pane 2 is also attached to Pane 1 so it gives a tab box effect.  

Any suggestions on how to do this?

Thanks,

- Adrian




Replies:
Posted By: kstowell
Date Posted: 07 July 2004 at 3:43pm

Hello,

Assuming that you have a CTreeCtrl member of your CFormView class as show below:

class CMyFormView : public CFormView
{
    ... code snip

protected:
    CTreeCtrl m_wndTreeCtrl;

public:
    CTreeCtrl& GetTreeCtrl() {
        return m_wndTreeCtrl;
    }
};

You could do the following:

CXTPDockingPane* pPane = m_paneManager.FindPane(ID_TO_YOURDOCKINGPANE);
CMyFormView* pFormView = DYNAMIC_DOWNCAST(CMyFormView, pPane->GetChild());
if (pFormView)
{
    CTreeCtrl& treeCtrl = pFormView->GetTreeCtrl();
}


Hope this helps...

Kind Regards,
Codejock Support



-------------
Kirk Stowell, President and CEO
CODEJOCK SOFTWARE SOLUTIONS<


Posted By: AdrianM
Date Posted: 07 July 2004 at 5:50pm

Thank you.  My m_paneManager is actually in my MainFrame.  So I modified the code to add CMainFrame in order to access m_paneManager...

CMainFrame* mf = (CMainFrame*)AfxGetMainWnd();
CXTPDockingPane* pPane = mf->m_paneManager.FindPane(IDD_MYFORMVIEW1);

CMyFormView1* pFormView = DYNAMIC_DOWNCAST(CMyFormView1, pPane->GetChild());
 
if (pFormView)
{

       CTreeCtrl& treeCtrl = pFormView->GetTreeCtrl();

}

It looks like its close to working.. but the only thing that is not working now is that pFormView is FALSE so the IF statement doesn't execute.  Did I call CMainFrame incorrectly?

 



Posted By: kstowell
Date Posted: 07 July 2004 at 6:04pm

Is is possible that your CFormView is nested in a CFrameWnd?  If so that would explain why DYNAMIC_DOWNCAST is returning NULL.  Please try this:

CMyFormView1* pFormView = NULL;

CWnd* pChildWnd = pPane->GetChild();
ASSERT_VALID(pChildWnd);

if (pChildWnd)
{
    if (pChildWnd->IsFrameWnd())
        pFormView = DYNAMIC_DOWNCAST(CMyFormView1,
             ((CFrameWnd*)pChildWnd)->GetActiveView());
    else
        pFormView = DYNAMIC_DOWNCAST(CMyFormView1, pChildWnd);
}

ASSERT_VALID(pFormView);
if (pFormView)
{
    CTreeCtrl& treeCtrl = pFormView->GetTreeCtrl();

}



hope this helps...



-------------
Kirk Stowell, President and CEO
CODEJOCK SOFTWARE SOLUTIONS<


Posted By: AdrianM
Date Posted: 07 July 2004 at 7:25pm

Hello,

This code asserts at:      ASSERT_VALID(pChildWnd);

I appreciate your help.

Best wishes,

- Adrian



Posted By: kstowell
Date Posted: 07 July 2004 at 8:05pm
Make sure you make the call AFTER you have attached the view to the pane.

-------------
Kirk Stowell, President and CEO
CODEJOCK SOFTWARE SOLUTIONS<


Posted By: AdrianM
Date Posted: 08 July 2004 at 1:34pm

 

The call to ASSERT_VALID (pChildWnd) is made after the call to create the pane.

- Adrian



Posted By: kstowell
Date Posted: 08 July 2004 at 7:44pm
And after your "Attach" or "AttachView" ?  If you try to call this before you attach the view, pChildWnd will be NULL.  If yes, then please upload a sample project so I can debug the problem, thanks.

-------------
Kirk Stowell, President and CEO
CODEJOCK SOFTWARE SOLUTIONS<



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