"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
See below...
On Wed, 22 Aug 2007 15:02:52 +0100, "GT" <ContactGT_removeme_@hotmail.com>
wrote:
"GT" <ContactGT_removeme_@hotmail.com> wrote in message
news:00238b8f$0$32142$c3e8da3@news.astraweb.com...
I create a dialog and call .DoModal() in the usual fashion. The dialog is
modal, so nothing else can be done on the application whilst working in
the
dialog. All OK so far! Problem is that this first dialog has a button
that
instantiated a sub dialog (of a different type) and does .DoModal() on
that. Once the second dialog has closed, focus is supposed to return to
the
first dialog and it should continue where it left off, problem is that
once
the second dialog has been closed, the first dialog no longer appears to
be
modal - you can select things from the main menu and do anything you like
in the rest of the application!
How do I return a dialog to the Modal state after a sub dialog has been
instantiated, called .DoModal(), and then closed.
Thanks
OK, scrap that problem - turns out that the second level dialog had
AfxGetMainWnd() as the parent (2nd) parameter in the call to construct the
base CDialog class! I have changed this to NULL and problem has gone away!
Does this sound like bad programming? There are a number of dialogs in the
application that inherit from a single base class, defined as
CDialogGeneric. Constructure looks like this:
CDialogGeneric::CDialogGeneric(int dialogID)
: CDialog(dialogID, NULL),
m_bDirty(false)
{
}
****
Consider rewriting it as
class CDIalogGeneric : public CDialog {
public:
CDialogGeneric(UINT dialogID, CWnd * parent = NULL);
and implement as
CDialogGeneric::CDialogGeneric(UINT dialogID, CWnd * parent /* = NULL*/ )
: CDialog(dialogID, parent) , ...
{
}
Then you can change the parent as necessary.
Note that resource IDs are UINTs, not ints.
joe
****
and pass when necessary.
Defaults the parent to the main window, but supplied when required.