ctreectrl problem

Hi! Here's a picture of my application <http://www.geocities.com/paulr_files/before.jpg>. As you can see its a simple ctreectrl inside a ctabctrl which is also inside a cformsview. I have overridden the OnSize of my MainFrm so that I can resize the views, tabs, tree properly. My problem is, when I select an item from the tree and then minimize it, upon restoring the window my tree gets screwed up. Here's a picture <http://www.geocities.com/paulr_files/after.jpg>. Here's part of my source code:


#pragma once
class CMainFrame : public CFrameWnd
protected: // create from serialization only

// Attributes

// Operations

// Overrides
      virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
    virtual BOOL OnCreateClient( LPCREATESTRUCT lpcs, CCreateContext *pContext );

// Implementation
      virtual ~CMainFrame();
#ifdef _DEBUG
      virtual void AssertValid() const;
      virtual void Dump(CDumpContext& dc) const;

protected:  // control bar embedded members
      CStatusBar  m_wndStatusBar;
      CToolBar    m_wndToolBar;
    CSplitterWnd m_wndMainSplitter;
    CSplitterWnd m_wndChildSplitter;

    CModuleView *m_wndModView;
    COgreView *m_wndOgreView;
    CObjectsView *m_wndObjectsView;
    CMessagesView *m_wndMessagesView;

// Generated message map functions
    afx_msg void OnSize( UINT nType, int cx, int cy );
      afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

Here's only part of MainFrm.cpp which I think is relevant:
// CMainFrame message handlers
afx_msg void CMainFrame::OnSize( UINT nType, int cx, int cy )
    CFrameWnd::OnSize( nType, cx, cy );
    //resize splitter panes here
    if( (splitterInit && nType != SIZE_MINIMIZED) ||
        (splitterInit && nType == SIZE_RESTORED) ) {
        m_wndMainSplitter.SetRowInfo( 0, cy-150, 50 );

        m_wndChildSplitter.SetColumnInfo( 0, 200, 50 );
        m_wndChildSplitter.SetColumnInfo( 1, cx-400, 50 );
        m_wndChildSplitter.SetColumnInfo( 2, 200, 50 );
        //resize tab on right with tree properly
        int width = 0;
        int height = 0;
        int tempIdeal = 0;

        m_wndMainSplitter.GetRowInfo( 0, height, tempIdeal );
        m_wndChildSplitter.GetColumnInfo( 2, width, tempIdeal );        
        m_wndObjectsView->m_wndTab.MoveWindow( 0, 50, width, height-50 );
        m_wndObjectsView->m_wndTree.MoveWindow( 5, 80, width-10, height-90 );            

As for the CFormView which holds the tree, I have overridden the OnInitialUpdate function:
void CObjectsView::OnInitialUpdate()
    //add stuff to the tree

I have already tried calling the Invalidate(), RedrawWindow(), and UpdateWindow() methods of the tree. But it still doesn't display itself when an item is selected, the window minimized, and restored.

If you want to view the entire project, you can get it at <http://www.geocities.com/paulr_files/proj.zip>. Its 600kb. Sorry for the hassle. I would really appreciate it if you could check it out.

If you can't figure this out, maybe you could at least tell me how to clear a tree. I've tried:


After calling this method, I can no longer attach any items to the tree. For example,

m_wndTree.InsertItem( "helloworld", TVI_ROOT, TVI_LAST );

helloworld doesn't appear in the tree. What am I missing here?

Thanks so much!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Are you repainting the tree ctrl when the application gets restored?
The view needs to check the tree selection and draw the tree content accordingly. I am missing this function in your code.

And it seems strange that the tab control spin is changing the position of tabs. It should just make other visible.
Hi paulr1984,

the re-draw problem seems to be simply a z-order problem: the tree-ctrl is drawn befor the tab-ctrl.

I just swapped the order of these in the dialog-resource, then it's re-drawn correctly ...

The other problem seems to be just a graphical problem ... If you re-size the mainframe after the DeleteAllItems() the new added items re-appear ... unfortunateley I have to leave my office now, but I'll try to continue bug-search tomorrow morning ...

hope that helps,


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
paulr1984Author Commented:
Your right zoppo.  Thanks.  But i already found the answer in my other post http://www.codeguru.com/forum/showthread.php?p=1044633#post1044633

I'm trying to save as much points as I can.  I'm forseeing several more spikes which can come up in my project.  Sorry Zoppo but I'll have to refund my points.  How do I do this again?
hm ... would have really been a good idea to tell us here there's no more need waste any time for nothing ...

Ask a question in community support if you want to refund the points ...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.