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. Doc/View application with docking pane

Doc/View application with docking pane

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studiomcpdata-structures
4 Posts 4 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.
  • G Offline
    G Offline
    Gagnon Claude
    wrote on last edited by
    #1

    Hi, I have a Visual Studio 2008 MFC doc/view application. I have choosed a docking pane type. The dock is a tree control like Windows explorer. When I click an item on the tree, I want to change the form in the view area. For that I have to acces the document to get a member function. The code is working but I get memory leak. Perhaps I don't take the good way. Any suggestions ? Claude Here's my code: void CViewTree::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR); // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle *pResult = 0; CString strItem; HTREEITEM hItem = GetSelectedItem(); strItem = GetItemText(hItem); // Pointeurs vers le document CFrameWnd *pFrameWnd = (CFrameWnd*)AfxGetApp()->m_pMainWnd; CCDSView* pView; pView = (CCDSView*)pFrameWnd->GetActiveView(); // // Detected memory leaks! //Dumping objects -> //{1272} normal block at 0x03E2C478, 530 bytes long. // Data: < 6 > 14 36 19 01 0F 00 00 00 00 01 00 00 01 00 00 00 //{1190} normal block at 0x03E28F20, 530 bytes long. // Data: < 6 ( > 14 36 19 01 28 00 00 00 00 01 00 00 01 00 00 00 //Object dump complete. CCDSDoc* pDoc = pView->GetDocument(); pDoc->ToDoc(strItem); }

    _ R S 3 Replies Last reply
    0
    • G Gagnon Claude

      Hi, I have a Visual Studio 2008 MFC doc/view application. I have choosed a docking pane type. The dock is a tree control like Windows explorer. When I click an item on the tree, I want to change the form in the view area. For that I have to acces the document to get a member function. The code is working but I get memory leak. Perhaps I don't take the good way. Any suggestions ? Claude Here's my code: void CViewTree::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR); // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle *pResult = 0; CString strItem; HTREEITEM hItem = GetSelectedItem(); strItem = GetItemText(hItem); // Pointeurs vers le document CFrameWnd *pFrameWnd = (CFrameWnd*)AfxGetApp()->m_pMainWnd; CCDSView* pView; pView = (CCDSView*)pFrameWnd->GetActiveView(); // // Detected memory leaks! //Dumping objects -> //{1272} normal block at 0x03E2C478, 530 bytes long. // Data: < 6 > 14 36 19 01 0F 00 00 00 00 01 00 00 01 00 00 00 //{1190} normal block at 0x03E28F20, 530 bytes long. // Data: < 6 ( > 14 36 19 01 28 00 00 00 00 01 00 00 01 00 00 00 //Object dump complete. CCDSDoc* pDoc = pView->GetDocument(); pDoc->ToDoc(strItem); }

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      The code that you have shown does not appear to have any memory leaks. Search for the new keyword or functions like HeapAlloc, GlobalAlloc, VirtualAlloc etc. in all the code. Then you can see if the allocated memory is being freed. Alternatively you can use the _CrtMemCheckpoint and _CrtMemDifference functions to find exactly where the memory leak happens.

      «_Superman_» I love work. It gives me something to do between weekends.

      1 Reply Last reply
      0
      • G Gagnon Claude

        Hi, I have a Visual Studio 2008 MFC doc/view application. I have choosed a docking pane type. The dock is a tree control like Windows explorer. When I click an item on the tree, I want to change the form in the view area. For that I have to acces the document to get a member function. The code is working but I get memory leak. Perhaps I don't take the good way. Any suggestions ? Claude Here's my code: void CViewTree::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR); // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle *pResult = 0; CString strItem; HTREEITEM hItem = GetSelectedItem(); strItem = GetItemText(hItem); // Pointeurs vers le document CFrameWnd *pFrameWnd = (CFrameWnd*)AfxGetApp()->m_pMainWnd; CCDSView* pView; pView = (CCDSView*)pFrameWnd->GetActiveView(); // // Detected memory leaks! //Dumping objects -> //{1272} normal block at 0x03E2C478, 530 bytes long. // Data: < 6 > 14 36 19 01 0F 00 00 00 00 01 00 00 01 00 00 00 //{1190} normal block at 0x03E28F20, 530 bytes long. // Data: < 6 ( > 14 36 19 01 28 00 00 00 00 01 00 00 01 00 00 00 //Object dump complete. CCDSDoc* pDoc = pView->GetDocument(); pDoc->ToDoc(strItem); }

        R Offline
        R Offline
        Rajesh R Subramanian
        wrote on last edited by
        #3

        How do you know there is a memory leak? Is the debugger dumping the objects after your application shuts down? In which case it must point out the line numbers where the leaking memory was allocated. If not, you need to add this to the beginning of your manually created source files (if a source file is added by any of the wizards, it adds this by default):

        #ifdef _DEBUG
        #define new DEBUG_NEW

        You may look at the definition of DEBUG_NEW to see what it does.

        It is a crappy thing, but it's life -^ Carlo Pallini

        1 Reply Last reply
        0
        • G Gagnon Claude

          Hi, I have a Visual Studio 2008 MFC doc/view application. I have choosed a docking pane type. The dock is a tree control like Windows explorer. When I click an item on the tree, I want to change the form in the view area. For that I have to acces the document to get a member function. The code is working but I get memory leak. Perhaps I don't take the good way. Any suggestions ? Claude Here's my code: void CViewTree::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR); // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle *pResult = 0; CString strItem; HTREEITEM hItem = GetSelectedItem(); strItem = GetItemText(hItem); // Pointeurs vers le document CFrameWnd *pFrameWnd = (CFrameWnd*)AfxGetApp()->m_pMainWnd; CCDSView* pView; pView = (CCDSView*)pFrameWnd->GetActiveView(); // // Detected memory leaks! //Dumping objects -> //{1272} normal block at 0x03E2C478, 530 bytes long. // Data: < 6 > 14 36 19 01 0F 00 00 00 00 01 00 00 01 00 00 00 //{1190} normal block at 0x03E28F20, 530 bytes long. // Data: < 6 ( > 14 36 19 01 28 00 00 00 00 01 00 00 01 00 00 00 //Object dump complete. CCDSDoc* pDoc = pView->GetDocument(); pDoc->ToDoc(strItem); }

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          See this page[^] (or this page[^] for newer versions of Visual Studio) for advice on how to get a debugger breakpoint when the allocation that's been detected as leaking occurs.

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

          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