Sam is right. But as he says, you didn't specify where in a modeless dialog you mean. It depends on how the dialog is managed. Most often, with a modeless dialog, you keep a pointer to the CDialog object somewhere in your code. The dialog is instantiated, and then you call Create() and ShowWindow(). Now in OnOk / OnCancel, you have the choice of just closing the dialog (by calling ShowWindow with SW_HIDE) and keep the window object alive (for later use). In that case, the code "outside" which created the dialog would just need to delete the CDialog object later without having to call DestroyWindow() (as it is called in the dtor). However, a frequent scenario is that you want to destroy the window object in OnOk / OnCancel. Calling "delete this" would be a bad idea in this case, as it would leave the "outside" pointer to the CDialog object dangling. That's why you call DestroyWindow() in that case, leaving the CDialog object (without a valid HWND) alive. In order to redisplay the dialog, the "outside" code would have to call Create() once again, and reuse just the existing CDialog instance.Quote:
Originally posted by brraj
what do u say about Sam Hobbs comments ?