Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Tree Ctrl

Tree Ctrl

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresdebuggingannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VVVimal
    wrote on last edited by
    #1

    // Add URL void LeftView::AddUrl(void) { CTreeCtrl& trCtrl = GetTreeCtrl(); HTREEITEM hitem,hitem1,hitem3; hitem = trCtrl.InsertItem(_T("URL"),TVI_ROOT,TVI_LAST); for(inti=0; i<arrLines.GetSize();i++) { CString str = arrLines.GetAt(i); trCtrl.InsertItem(str,hitem,TVI_LAST); intk; } } // REad text arrLines.RemoveAll(); CString pszFileName(_T("D:\\URL\\TextFile.txt")); CString strLine =_T(""); TRY { CStdioFile file(pszFileName, CFile::modeRead); while( file.ReadString(strLine)) { arrLines.Add(strLine); } } CATCH_ALL(e) { e->ReportError(); // shows what's going wrong } END_CATCH_ALL void LeftView::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult) { /**/ NM_TREEVIEW *pNMTreeView = (NM_TREEVIEW *) pNMHDR; CTreeCtrl &tTree = this->GetTreeCtrl (); /**/ CString str("Test"); sFullList=" "; sFullList += tTree.GetItemText(pNMTreeView->itemNew.hItem); if( sFullList.CompareNoCase("URL") == 0) { GetDocument ()->UpdateAllViews ( this, 1L, (CObject *) &sFullList ); } *pResult = 0; } BOOL LeftView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Add your specialized code here and/or call the base class cs.style |= TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_EDITLABELS; returnCTreeView::PreCreateWindow(cs); } CSplitterWindowDoc* LeftView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSplitterWindowDoc))); return(CSplitterWindowDoc*)m_pDocument; } void CSplitterWindowView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { // TODO: Add your specialized code here and/or call the base class if(lHint==1L) { CString sListToDisplay = ((CString*)pHint)->GetBuffer(0); Navigate2(sListToDisplay,NULL,NULL); } CSingleDocTemplate* pDocTemplate; pDocTemplate = newCSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CSplitterWindowDoc),

    N 1 Reply Last reply
    0
    • V VVVimal

      // Add URL void LeftView::AddUrl(void) { CTreeCtrl& trCtrl = GetTreeCtrl(); HTREEITEM hitem,hitem1,hitem3; hitem = trCtrl.InsertItem(_T("URL"),TVI_ROOT,TVI_LAST); for(inti=0; i<arrLines.GetSize();i++) { CString str = arrLines.GetAt(i); trCtrl.InsertItem(str,hitem,TVI_LAST); intk; } } // REad text arrLines.RemoveAll(); CString pszFileName(_T("D:\\URL\\TextFile.txt")); CString strLine =_T(""); TRY { CStdioFile file(pszFileName, CFile::modeRead); while( file.ReadString(strLine)) { arrLines.Add(strLine); } } CATCH_ALL(e) { e->ReportError(); // shows what's going wrong } END_CATCH_ALL void LeftView::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult) { /**/ NM_TREEVIEW *pNMTreeView = (NM_TREEVIEW *) pNMHDR; CTreeCtrl &tTree = this->GetTreeCtrl (); /**/ CString str("Test"); sFullList=" "; sFullList += tTree.GetItemText(pNMTreeView->itemNew.hItem); if( sFullList.CompareNoCase("URL") == 0) { GetDocument ()->UpdateAllViews ( this, 1L, (CObject *) &sFullList ); } *pResult = 0; } BOOL LeftView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Add your specialized code here and/or call the base class cs.style |= TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_EDITLABELS; returnCTreeView::PreCreateWindow(cs); } CSplitterWindowDoc* LeftView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSplitterWindowDoc))); return(CSplitterWindowDoc*)m_pDocument; } void CSplitterWindowView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { // TODO: Add your specialized code here and/or call the base class if(lHint==1L) { CString sListToDisplay = ((CString*)pHint)->GetBuffer(0); Navigate2(sListToDisplay,NULL,NULL); } CSingleDocTemplate* pDocTemplate; pDocTemplate = newCSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CSplitterWindowDoc),

      N Offline
      N Offline
      Niklas L
      wrote on last edited by
      #2

      Use GetSelectedItem[^] and compare it to your root HTREEITEM using GetRootItem[^] Also, wrapping code into <pre></pre> tags will make it more readable.

      home

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups