paulr1984
asked on
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:
MainFrm.h
[code]
#pragma once
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFra me)
// Attributes
public:
// Operations
public:
// Overrides
public:
virtual BOOL PreCreateWindow(CREATESTRU CT& 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.SetRowIn fo( 0, cy-150, 50 );
m_wndMainSplitter.RecalcLa yout();
m_wndChildSplitter.SetColu mnInfo( 0, 200, 50 );
m_wndChildSplitter.SetColu mnInfo( 1, cx-400, 50 );
m_wndChildSplitter.SetColu mnInfo( 2, 200, 50 );
m_wndChildSplitter.RecalcL ayout();
//resize tab on right with tree properly
int width = 0;
int height = 0;
int tempIdeal = 0;
m_wndMainSplitter.GetRowIn fo( 0, height, tempIdeal );
m_wndChildSplitter.GetColu mnInfo( 2, width, tempIdeal );
m_wndObjectsView->m_wndTab .MoveWindo w( 0, 50, width, height-50 );
m_wndObjectsView->m_wndTre e.MoveWind ow( 5, 80, width-10, height-90 );
}
}
[/code]
As for the CFormView which holds the tree, I have overridden the OnInitialUpdate function:
[code]
void CObjectsView::OnInitialUpd ate()
{
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!
MainFrm.h
[code]
#pragma once
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFra
// Attributes
public:
// Operations
public:
// Overrides
public:
virtual BOOL PreCreateWindow(CREATESTRU
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.SetRowIn
m_wndMainSplitter.RecalcLa
m_wndChildSplitter.SetColu
m_wndChildSplitter.SetColu
m_wndChildSplitter.SetColu
m_wndChildSplitter.RecalcL
//resize tab on right with tree properly
int width = 0;
int height = 0;
int tempIdeal = 0;
m_wndMainSplitter.GetRowIn
m_wndChildSplitter.GetColu
m_wndObjectsView->m_wndTab
m_wndObjectsView->m_wndTre
}
}
[/code]
As for the CFormView which holds the tree, I have overridden the OnInitialUpdate function:
[code]
void CObjectsView::OnInitialUpd
{
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!
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.
And it seems strange that the tab control spin is changing the position of tabs. It should just make other visible.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
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 ...
Ask a question in community support if you want to refund the points ...