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. Problems with destroying a dialog box

Problems with destroying a dialog box

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

    I create another dialog box from my main dialog box. I want to show it and remove it when i want, without the user's will. I call the show function and the remove function from different places, and 90% I am able to remove it. For the other 10% I tried calling DestroyWindow() to remove, or calling it in the class destructor. I also tried overriding PostNcDestroy() and calling CDialog::PostNcDestroy() inside, etc. OnDestroy(), PostNcDestroy() and OnNcDestroy() are called respectively, but I keep seeing the dialog box, it is not removed. Can someone please help me? How can I destroy it properly? Thanks in advance To show: pOtherBox = new COtherBox(); BOOL ret = pOtherBox->Create(IDD_OTHERBOX, this); pOtherBox->SetWindowPos(&this->wndTopMost, left,top,width,height, SWP_NOREPOSITION|SWP_NOSENDCHANGING|SWP_NOACTIVATE|SWP_SHOWWINDOW); To remove: if(pOtherBox!=NULL) { delete pOtherBox; //pOtherBox->DestroyWindow(); //also tried instead of delete pOtherBox = NULL; }

    D 1 Reply Last reply
    0
    • C caykahve

      I create another dialog box from my main dialog box. I want to show it and remove it when i want, without the user's will. I call the show function and the remove function from different places, and 90% I am able to remove it. For the other 10% I tried calling DestroyWindow() to remove, or calling it in the class destructor. I also tried overriding PostNcDestroy() and calling CDialog::PostNcDestroy() inside, etc. OnDestroy(), PostNcDestroy() and OnNcDestroy() are called respectively, but I keep seeing the dialog box, it is not removed. Can someone please help me? How can I destroy it properly? Thanks in advance To show: pOtherBox = new COtherBox(); BOOL ret = pOtherBox->Create(IDD_OTHERBOX, this); pOtherBox->SetWindowPos(&this->wndTopMost, left,top,width,height, SWP_NOREPOSITION|SWP_NOSENDCHANGING|SWP_NOACTIVATE|SWP_SHOWWINDOW); To remove: if(pOtherBox!=NULL) { delete pOtherBox; //pOtherBox->DestroyWindow(); //also tried instead of delete pOtherBox = NULL; }

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

      To dismiss the modeless dialog box, simply call: pOtherBox->DestroyWindow(); And also implement:

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


      "Take only what you need and leave the land as you found it." - Native American Proverb

      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