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. Question about console windows

Question about console windows

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformance
3 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.
  • N Offline
    N Offline
    nachilau
    wrote on last edited by
    #1

    Hello all, I have written a program which contains a GUI windows and also a console windows. When the program start, I allocate a console window from Windows. When the user close the console window during the programming is running, my main GUI get closed at the same time too. What I think is that may be the console window process is a child process of the main GUI window, when the child prcoess get closed, its parent process will also be destoryed. However, the destcutor of my main GUI porcess didn't get called when the console get closed which cause a lot of memory leaks. Do anyone know why my main GUI window destructor did get called when one of it child process get closed? :)

    R 1 Reply Last reply
    0
    • N nachilau

      Hello all, I have written a program which contains a GUI windows and also a console windows. When the program start, I allocate a console window from Windows. When the user close the console window during the programming is running, my main GUI get closed at the same time too. What I think is that may be the console window process is a child process of the main GUI window, when the child prcoess get closed, its parent process will also be destoryed. However, the destcutor of my main GUI porcess didn't get called when the console get closed which cause a lot of memory leaks. Do anyone know why my main GUI window destructor did get called when one of it child process get closed? :)

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      nachilau wrote:

      I have written a program which contains a GUI windows and also a console windows. When the program start, I allocate a console window from Windows.

      How are you doing that exactely ?

      nachilau wrote:

      when the child prcoess get closed, its parent process will also be destoryed

      Certainly not. ~RaGE();

      N 1 Reply Last reply
      0
      • R Rage

        nachilau wrote:

        I have written a program which contains a GUI windows and also a console windows. When the program start, I allocate a console window from Windows.

        How are you doing that exactely ?

        nachilau wrote:

        when the child prcoess get closed, its parent process will also be destoryed

        Certainly not. ~RaGE();

        N Offline
        N Offline
        nachilau
        wrote on last edited by
        #3

        The way that I do it is AllocConsole(); m_hout = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleMode(m_hout, ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT); If you say that it is not true that when the child process get deleted, the parent process also get deleted, then I don't understand why my GUI get closed when the user close the console window.

        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