CTabView problem - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22

Thread: CTabView problem

  1. #16
    Join Date
    Jan 2009
    Posts
    183

    Re: CTabView problem

    Kindly thank Victor ... it help me, though sometime it doesn't draw ok whole CListView ... but your post lead me to solve the problem.
    Last edited by mesajflaviu; April 11th, 2017 at 01:08 PM.

  2. #17
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    18,907

    Re: CTabView problem

    You are welcome!
    Victor Nijegorodov

  3. #18
    Join Date
    Jan 2009
    Posts
    183

    Re: CTabView problem

    I realize that is not only scrollbar redrawing problem, it is entire CLIstView redrawing problem, and it is showing up just after I inserted a new view in tab dynamically, at run time ...

  4. #19
    Join Date
    Jan 2009
    Posts
    183

    Re: CTabView problem

    Here is the method that insert new view in tabview at runtime:
    Code:
    int CExploreTabbedView::AddView(CRuntimeClass* pViewClass, const CString& strViewLabel, int iIndex /*= -1*/, CCreateContext* pContext/* = NULL*/, BOOL bAfterCreation/* = FALSE*/)
    {
    	ASSERT_VALID(this);
    	ENSURE(pViewClass != NULL);
    	ENSURE(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CView)));
    
    	CView* pView = DYNAMIC_DOWNCAST(CView, pViewClass->CreateObject());
    	ASSERT_VALID(pView);
    
    	if(! pView->Create(NULL, _T(""), WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), &m_wndTabs, (UINT)-1, pContext))
    	{
    		TRACE1(_T("CTabView:Failed to create view '%s'\n"), pViewClass->m_lpszClassName);
    		return -1;
    	}
    
    	CDocument* pDoc = GetDocument();
    	if (pDoc != NULL)
    	{
    		ASSERT_VALID(pDoc);
    
    		BOOL bFound = FALSE;
    		for (POSITION pos = pDoc->GetFirstViewPosition();! bFound && pos != NULL;)
    		{
    			if(pDoc->GetNextView(pos) == pView)
    				bFound = TRUE;
    		}
    		if(! bFound)
    			pDoc->AddView(pView);
    	}
    
    	if(bAfterCreation)
    		pView->SendMessage(WM_INITIALUPDATE, 0, 0);
    
    	m_wndTabs.InsertTab(pView, strViewLabel, iIndex);
    
    	int nTabs = m_wndTabs.GetTabsNum();
    	return nTabs - 1;
    }
    still, after I use this method, the problems begin ...

  5. #20
    Join Date
    Jan 2009
    Posts
    183

    Re: CTabView problem

    I have noticed that soon as I remove a tab, using CTabView::RemoveView, the tab index doesn't fit by CView attached with tab ...

    I put here another sample project that demonstrate the problem ... could be a framework bug ?
    Attached Files Attached Files

  6. #21
    Join Date
    Jan 2009
    Posts
    183

    Re: CTabView problem [synthesis]

    I have found the source of the problem: as once as I call CTabView::RemoveView, the order of the remaining views are altered.

    In order to reproduce this:

    Go to "With test-form-view":
    https://s23.postimg.org/hagpo37pn/Zr_LDh.png
    Drag CTestFormView as first tab:
    https://s29.postimg.org/fid6m9rnr/unkgp.png
    Select, let's say, CExploreListView4:
    https://s13.postimg.org/wbdoheo3r/Kas5l.png
    Select "Without test-form-view" item in left view:
    https://s11.postimg.org/i64pna7lv/KJ6z9.png
    The "CTestFormView" has disappeared from CTabView, and the first tab is selected. Right-click on this CExploreListView1, and you will see the context menu of CExploreListView4, not the context menu of CExploreListView1.
    If you select another treeitem from leftview ("With-test-form-view"), which add CTestFormView, then all listviews from CTabView are not redrawn correctly. Is there a bug in CTabView ?

  7. #22
    Join Date
    Jan 2009
    Posts
    183

    Re: CTabView problem

    I have found a workaround, in case that somebody would have this problem: I have used
    CMFCTabCtrl::ShowTab(...) instead of CTabView::RemoveView/CTabView::AddView, which cause me a lot of problems ... thank you for all your support.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)