Hello.

I found an interesting behavior with modeless dialog boxes in Visual C++
6.0. Actually, I must do something wrong, so bear with me ... it can be
reproduced in a couple of minutes if you have the time. ;-)

Basically, once I open up a modeless dialog box, I can iconize the
application and bring it back up, and the box is still there. But once
I close it with OK or CANCEL then open it up again, iconize the app and
bring the app back up, the box has disappeared.

---------------------

Now, it may be that the way I build those boxes is the problem here, so
I'll submit my code here for comments. To reproduce the error, do the
following :

1) Use the MFC AppWizard to create an create a Single Document application.

2) Add a simple dialog box in the ressource editor with no bells or
whistles. Kist the standard OK and CANCEL button. Create a new class
with ClassWizard for this dialog.

3) Add a single menu item to call the dialog box. Use ClassWizard to
create a command message with this menu item. For my tests, I have
created this message on two seperates apps, one using the CMainFrame
class, the other using the application-defined View class. Both give
identical results, so I don't think that either location is better in
this case.

4) Depending if you use CMainFrame class or the View class, add to its
header file the appropriate #include from the dialog box's class. Add
an a pointer to this class as a member value. Set the pointer to NULL
in the class contructor


So far you should have something like this (this exemple uses CMainFrame) :

///////////////////////

class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)

// Attributes
public:
MyDlg *dlg;

....
}

....

CMainFrame::CMainFrame()
{

// TODO: add member initialization code here
dlg = NULL;

}
///////////////////////

5) Now the nitty-gritty: add this code to the function called by the menu:

//////////////////////

void CMainFrame::OnShowMydlg()
{
if (!dlg)
{
if ((dlg = (MyDlg *) new MyDlg()))
dlg->Create(IDD_DIALOG1, this);
}

if (dlg)
{
dlg->ShowWindow(!dlg->IsWindowVisible());
}
}

///////////////////////

Compile and run. Activate the box with the help of the menu. Since the
pointer is null, it will create a new Dialog box and show it. Use
*only* the menu to toggle the box. Minimize the app while the box is
showing and bring it back up: the box is still there.

But if you use the OK or CANCEL button, or click on the top X, show the
box again using the menu then iconize the app. Bring it back up: voilą!
The box has disappeared.

I guess it all comes down with the way I'm build my modeless box. Or
some extra code I need to deal with in order to restore the dialog box
properly. If anybody has insights about this, let me know.

Cheers.