Nonmodal dialog cancel itself without any user input
Posted on 2006-03-20
I have a nonmodal dialog that opens a couple of files. If the files don't exist, I want the dialog to tell the user, then close itself. I can get right to the point of closing itself, and then I am stumped. Whatever I do, generates an error message. In other words, I want something like if(!file)OnCancel(). I tried going back to the function that created the dialog, doing something like if(!pDlg->file)..., but I still get an error. I believe it is because the dialog has not finished being created, so attempting to destroy it is premature. Anyway, I am tempted to try a timer, but I hope that someone here has a better answer. Perhaps I should send a message from the calling function as in if(!pDlg->file)send a close message. It would certainly help if I better understood the process of dialog and window creation.
BTW, I know that I can open the files before creating the dialog, but that will create other problems, and I still won't understand this issue.
Anyway, thanks in advance, Rick