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