Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ctreectrl problem

Posted on 2004-11-10
6
Medium Priority
?
650 Views
Last Modified: 2013-11-20
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:

MainFrm.h

[code]
#pragma once
class CMainFrame : public CFrameWnd
{
      
protected: // create from serialization only
      CMainFrame();
      DECLARE_DYNCREATE(CMainFrame)

// Attributes
public:

// Operations
public:

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

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

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

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


// Generated message map functions
protected:
    afx_msg void OnSize( UINT nType, int cx, int cy );
      afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
      DECLARE_MESSAGE_MAP()
};
[/code]

Here's only part of MainFrm.cpp which I think is relevant:
[code]
// 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_wndMainSplitter.RecalcLayout();        

        m_wndChildSplitter.SetColumnInfo( 0, 200, 50 );
        m_wndChildSplitter.SetColumnInfo( 1, cx-400, 50 );
        m_wndChildSplitter.SetColumnInfo( 2, 200, 50 );
        m_wndChildSplitter.RecalcLayout();
       
        //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 );            
    }    
}
[/code]

As for the CFormView which holds the tree, I have overridden the OnInitialUpdate function:
[code]
void CObjectsView::OnInitialUpdate()
{
    CFormView::OnInitialUpdate();
    //add stuff to the tree
}
[/code]

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:

m_wndTree.DeleteAllItems()

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

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

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

Thanks so much!
0
Comment
Question by:paulr1984
  • 2
  • 2
5 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 12546247
Are you repainting the tree ctrl when the application gets restored?
0
 
LVL 13

Expert Comment

by:SteH
ID: 12546272
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.
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 800 total points
ID: 12556567
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,

ZOPPO
0
 

Author Comment

by:paulr1984
ID: 12562431
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?
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 12563327
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 ...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question