newbie seeks CtreeView, tree! - Programmer

This is a discussion on newbie seeks CtreeView, tree! - Programmer ; I'm trying to put a CtreeView in a splitter window (MFC). According to a book I have I do this, in the MainFrm class OnCreateClient() ... if(!m_SplitWin.CreateStatic(this,1,2) || // n rows m cols of splitter panes !m_SplitWin.CreateView(0,0,RUNTIME_CLASS(CTreeView ), // tree ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: newbie seeks CtreeView, tree!

  1. newbie seeks CtreeView, tree!

    I'm trying to put a CtreeView in a splitter window (MFC).

    According to a book I have I do this, in the MainFrm class OnCreateClient() ...


    if(!m_SplitWin.CreateStatic(this,1,2) || // n rows m cols of splitter panes
    !m_SplitWin.CreateView(0,0,RUNTIME_CLASS(CTreeView ), // tree part
    CSize(512,0), pContext) ||
    !m_SplitWin.CreateView(0,1,RUNTIME_CLASS(CRichEdit View), // text part
    CSize(0,0),pContext))
    return FALSE;

    This works in that I get a split window ok, but I don't know how to
    access the CTreeView object (which doesn't yet exist does it?).


    I think I need to write

    CtreeCtrl& tree = GetTreeCtrl(); // this from some other book

    But the above lines was from a book that started out by inheriting its view
    class from CTreeExView in the initial MFC wizard build. (And is not splitter
    wondow, so is probably inappropriate here anyway?)

    I'd appreciate a line or two of actual code to get the CtreeView object created
    and accessed if possible?
    Thanks


  2. Re: newbie seeks CtreeView, tree!

    mike wrote:
    > I'm trying to put a CtreeView in a splitter window (MFC).
    >
    > According to a book I have I do this, in the MainFrm class OnCreateClient() ...
    >
    >
    > if(!m_SplitWin.CreateStatic(this,1,2) || // n rows m cols of splitter panes
    > !m_SplitWin.CreateView(0,0,RUNTIME_CLASS(CTreeView ), // tree part
    > CSize(512,0), pContext) ||
    > !m_SplitWin.CreateView(0,1,RUNTIME_CLASS(CRichEdit View), // text part
    > CSize(0,0),pContext))
    > return FALSE;
    >
    > This works in that I get a split window ok, but I don't know how to
    > access the CTreeView object (which doesn't yet exist does it?).


    Yes, it does exist after CreateView returns.

    It is a child window of the splitter. To access it from the mainframe
    you could do this...
    CTreeView* pTree = (CTreeView*)m_SplitWin.GetPane(0,0);

    --
    Scott McPhillips [VC++ MVP]


+ Reply to Thread