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. Dialog death

Dialog death

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++debugging
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.
  • O Offline
    O Offline
    Oliver123
    wrote on last edited by
    #1

    What does clicking the "X" box in the upper right corner of a dialog do? I'm puzzled by the behavior I am observing, and would like to understand it better. Below I describe two situations with very different results which seem to depend on clicking that box. SITUATION A void CDlgControl::OnBUTTONCreateLadder() { pLD = new CLadder; } void CDlgControl::OnBUTTONTestButton() { pLD->DestroyWindow(); delete pLD; pLD = NULL; } In SITUATION A above, the dialog is created and displayed. Debug shows it progressing through each command in OnBUTTONTestButton(). Debug then traces it through many Windows functions until it finally reaches a window titled Disassembly where it fails on a command 7E41B517 call 7E4194A4 Debug assertion failure File Winocc.cpp When not using Debug, it simply fails on the same message SITUATION B The same exact code is used. However, prior to executing OnBUTTONTestButton(), I click the "X" box in the upper right corner of the CLadder window. Then I execute OnBUTTONTestButton(), and everything works just fine. QUESTION: What does that "X" box do? What makes SITUATION A different from SITUATION B? Thanks

    G T F 3 Replies Last reply
    0
    • O Oliver123

      What does clicking the "X" box in the upper right corner of a dialog do? I'm puzzled by the behavior I am observing, and would like to understand it better. Below I describe two situations with very different results which seem to depend on clicking that box. SITUATION A void CDlgControl::OnBUTTONCreateLadder() { pLD = new CLadder; } void CDlgControl::OnBUTTONTestButton() { pLD->DestroyWindow(); delete pLD; pLD = NULL; } In SITUATION A above, the dialog is created and displayed. Debug shows it progressing through each command in OnBUTTONTestButton(). Debug then traces it through many Windows functions until it finally reaches a window titled Disassembly where it fails on a command 7E41B517 call 7E4194A4 Debug assertion failure File Winocc.cpp When not using Debug, it simply fails on the same message SITUATION B The same exact code is used. However, prior to executing OnBUTTONTestButton(), I click the "X" box in the upper right corner of the CLadder window. Then I execute OnBUTTONTestButton(), and everything works just fine. QUESTION: What does that "X" box do? What makes SITUATION A different from SITUATION B? Thanks

      G Offline
      G Offline
      Gary R Wheeler
      wrote on last edited by
      #2

      The "X" button issues a WM_SYSCOMMAND[^] notification to be sent to the window, with the wParam value set to SC_CLOSE. The default window handling closes the window. With situation B, the window has already been destroyed by the time OnBUTTONTestButton is called, so a great deal of the normal window shutdown logic has already occurred. There's something wrong in the way you're handling the window destruction, or possibly in the CLadder destructor. Without seeing more of the CLadder code, it's difficult to say.


      Software Zen: delete this;

      Fold With Us![^]

      1 Reply Last reply
      0
      • O Oliver123

        What does clicking the "X" box in the upper right corner of a dialog do? I'm puzzled by the behavior I am observing, and would like to understand it better. Below I describe two situations with very different results which seem to depend on clicking that box. SITUATION A void CDlgControl::OnBUTTONCreateLadder() { pLD = new CLadder; } void CDlgControl::OnBUTTONTestButton() { pLD->DestroyWindow(); delete pLD; pLD = NULL; } In SITUATION A above, the dialog is created and displayed. Debug shows it progressing through each command in OnBUTTONTestButton(). Debug then traces it through many Windows functions until it finally reaches a window titled Disassembly where it fails on a command 7E41B517 call 7E4194A4 Debug assertion failure File Winocc.cpp When not using Debug, it simply fails on the same message SITUATION B The same exact code is used. However, prior to executing OnBUTTONTestButton(), I click the "X" box in the upper right corner of the CLadder window. Then I execute OnBUTTONTestButton(), and everything works just fine. QUESTION: What does that "X" box do? What makes SITUATION A different from SITUATION B? Thanks

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        ModalDialog should call EndDialog instead of DestoryWindow, then you could delete the pointer of Dialog Variable.

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
        Never mind - my own stupidity is the source of every "problem" - Mixture

        cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

        1 Reply Last reply
        0
        • O Oliver123

          What does clicking the "X" box in the upper right corner of a dialog do? I'm puzzled by the behavior I am observing, and would like to understand it better. Below I describe two situations with very different results which seem to depend on clicking that box. SITUATION A void CDlgControl::OnBUTTONCreateLadder() { pLD = new CLadder; } void CDlgControl::OnBUTTONTestButton() { pLD->DestroyWindow(); delete pLD; pLD = NULL; } In SITUATION A above, the dialog is created and displayed. Debug shows it progressing through each command in OnBUTTONTestButton(). Debug then traces it through many Windows functions until it finally reaches a window titled Disassembly where it fails on a command 7E41B517 call 7E4194A4 Debug assertion failure File Winocc.cpp When not using Debug, it simply fails on the same message SITUATION B The same exact code is used. However, prior to executing OnBUTTONTestButton(), I click the "X" box in the upper right corner of the CLadder window. Then I execute OnBUTTONTestButton(), and everything works just fine. QUESTION: What does that "X" box do? What makes SITUATION A different from SITUATION B? Thanks

          F Offline
          F Offline
          Florin Crisan
          wrote on last edited by
          #4

          You may want to use Spy++ (it comes with Visual Studio) to see what messages are being passed to windows ;)

          Florin Crişan

          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