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. Closing a dialog app window

Closing a dialog app window

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

    I want to detect when a user closes a window by clicking on the X in the title bar. I dont know how to create a message map to catch the event. When I close the Window, I want to delete the CWnd object associated with that Window. :) Thanks. Jerry

    R P 2 Replies Last reply
    0
    • J jerry1211a

      I want to detect when a user closes a window by clicking on the X in the title bar. I dont know how to create a message map to catch the event. When I close the Window, I want to delete the CWnd object associated with that Window. :) Thanks. Jerry

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      Handle WM_SYSCOMMAND, specifically the SC_CLOSE case. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      1 Reply Last reply
      0
      • J jerry1211a

        I want to detect when a user closes a window by clicking on the X in the title bar. I dont know how to create a message map to catch the event. When I close the Window, I want to delete the CWnd object associated with that Window. :) Thanks. Jerry

        P Offline
        P Offline
        PJ Arends
        wrote on last edited by
        #3

        jerry1211a wrote: I want to detect when a user closes a window by clicking on the X in the title bar. Handle the WM_CLOSE message (CWnd::OnClose()). jerry1211a wrote: When I close the Window, I want to delete the CWnd object associated with that Window. If you are doing this from the window that is being closed, then the proper place to do it is in the PostNcDestroy() function

        void CMyWindow::PostNcDestroy()
        {
        delete this;
        }


        "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!

        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