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. Where does the m_pMainWnd delete?

Where does the m_pMainWnd delete?

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestion
5 Posts 3 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.
  • Y Offline
    Y Offline
    yu jian
    wrote on last edited by
    #1

    I have a client system, to create a CMainFrame object, but I am afraid that there will be memory leak about CMainFrame object.After step in, I cannot find where the m_pMainWnd pointer is deleted. Will I delete this pointer in the function ExitInstance()? :-D

    BOOL CApp::InitInstance()
    {
    CMainFrame* pMainFrame = new CMainFrame();
    if (!pMainFrame) return FALSE;
    pMainFrame->LoadFrame(IDR_MAINFRAME,
    WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
    NULL);
    m_pMainWnd = pMainFrame;
    m_pMainWnd->UpdateWindow();
    return TRUE;
    }

    int CApp::ExitInstance()
    {
    return CWinApp::ExitInstance();
    }

    D 1 Reply Last reply
    0
    • Y yu jian

      I have a client system, to create a CMainFrame object, but I am afraid that there will be memory leak about CMainFrame object.After step in, I cannot find where the m_pMainWnd pointer is deleted. Will I delete this pointer in the function ExitInstance()? :-D

      BOOL CApp::InitInstance()
      {
      CMainFrame* pMainFrame = new CMainFrame();
      if (!pMainFrame) return FALSE;
      pMainFrame->LoadFrame(IDR_MAINFRAME,
      WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
      NULL);
      m_pMainWnd = pMainFrame;
      m_pMainWnd->UpdateWindow();
      return TRUE;
      }

      int CApp::ExitInstance()
      {
      return CWinApp::ExitInstance();
      }

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      yu-jian wrote:

      After step in, I cannot find where the m_pMainWnd pointer is deleted.

      It's handled automatically by the framework.

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

      Y 1 Reply Last reply
      0
      • D David Crow

        yu-jian wrote:

        After step in, I cannot find where the m_pMainWnd pointer is deleted.

        It's handled automatically by the framework.

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

        Y Offline
        Y Offline
        yu jian
        wrote on last edited by
        #3

        Oh, sorry, I do not use the .net. This is the unmanaged C++. I cannot see where the system delete this pointer in file appcore.cpp. :)

        D J 2 Replies Last reply
        0
        • Y yu jian

          Oh, sorry, I do not use the .net. This is the unmanaged C++. I cannot see where the system delete this pointer in file appcore.cpp. :)

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          yu-jian wrote:

          Oh, sorry, I do not use the .net.

          What does that have to do with anything?

          yu-jian wrote:

          This is the unmanaged C++.

          If you mean this is the unmanaged C++ forum, of course it is. Did something indicate otherwise?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

          1 Reply Last reply
          0
          • Y yu jian

            Oh, sorry, I do not use the .net. This is the unmanaged C++. I cannot see where the system delete this pointer in file appcore.cpp. :)

            J Offline
            J Offline
            Jochen Arndt
            wrote on last edited by
            #5

            It is is deleted inside CFrameWnd::PostNcDestroy() (see winfrm.cpp) which is called by CWnd::OnNcDestroy which is the last member function called when the Windows window is destroyed.

            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