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. How to destroy several instances of a dialog-derived class?

How to destroy several instances of a dialog-derived class?

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

    Let's say my application has a pointer to a CDialog derived class and I create some modeless dialogs.(More than one!). My question is how to destroy all of them - myPointer->DestroyWindow() - for the last created one and after that how to redirect the pointer to the rest of the dialogs in order to destroy all of them?

    L 1 Reply Last reply
    0
    • J julych

      Let's say my application has a pointer to a CDialog derived class and I create some modeless dialogs.(More than one!). My question is how to destroy all of them - myPointer->DestroyWindow() - for the last created one and after that how to redirect the pointer to the rest of the dialogs in order to destroy all of them?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You can use DestroyWindow() to delete the underlying MFC windows handle. Obviously, if you use this on a dialog this will delete all the underlying child handles associated with that dialog box. Another method is to use PostMessage(WM_CLOSE, 0, 0), which is the method I prefer. To destroy a chain of dialog associated with each other you could try SendMessageToSiblings(WM_CLOSE). This will filter through a dialog box chain sending the message to each sibling (To be honst I've never used this method so I don't know if it will work). If you wanted to get all object orientated about it you could look at using the composite design pattern. This design pattern is used to forming complex tree structures and works brillantly for distributing messages across its tree structure.

      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