Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Docking Pane
  New Posts New Posts RSS Feed - How to access control on Pane1 from Pane2
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to access control on Pane1 from Pane2

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


Joined: 08 August 2003
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote AdrianM Quote  Post ReplyReply Direct Link To This Post Topic: How to access control on Pane1 from Pane2
    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



Edited by AdrianM
Back to Top
kstowell View Drop Down
Admin Group
Admin Group


Joined: 25 January 2003
Location: MIchigan, USA
Status: Offline
Points: 496
Post Options Post Options   Thanks (0) Thanks(0)   Quote kstowell Quote  Post ReplyReply Direct Link To This Post 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<
Back to Top
AdrianM View Drop Down
Newbie
Newbie


Joined: 08 August 2003
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote AdrianM Quote  Post ReplyReply Direct Link To This Post 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?

 

Back to Top
kstowell View Drop Down
Admin Group
Admin Group


Joined: 25 January 2003
Location: MIchigan, USA
Status: Offline
Points: 496
Post Options Post Options   Thanks (0) Thanks(0)   Quote kstowell Quote  Post ReplyReply Direct Link To This Post 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<
Back to Top
AdrianM View Drop Down
Newbie
Newbie


Joined: 08 August 2003
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote AdrianM Quote  Post ReplyReply Direct Link To This Post Posted: 07 July 2004 at 7:25pm

Hello,

This code asserts at:      ASSERT_VALID(pChildWnd);

I appreciate your help.

Best wishes,

- Adrian

Back to Top
kstowell View Drop Down
Admin Group
Admin Group


Joined: 25 January 2003
Location: MIchigan, USA
Status: Offline
Points: 496
Post Options Post Options   Thanks (0) Thanks(0)   Quote kstowell Quote  Post ReplyReply Direct Link To This Post 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<
Back to Top
AdrianM View Drop Down
Newbie
Newbie


Joined: 08 August 2003
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote AdrianM Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2004 at 1:34pm

 

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

- Adrian

Back to Top
kstowell View Drop Down
Admin Group
Admin Group


Joined: 25 January 2003
Location: MIchigan, USA
Status: Offline
Points: 496
Post Options Post Options   Thanks (0) Thanks(0)   Quote kstowell Quote  Post ReplyReply Direct Link To This Post 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<
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.203 seconds.