CDialog::Create never returns when it contains a CPropertySheet
Posted on 2004-03-24
I have a modeless property sheet that worked perfectly (under all of 95/98/ME/NT/2K/XP), but I wanted to make this dockable. I also have several modeless dialogs that I wanted to make dockable, so for simplicity I wanted to create a class derived from CDialogBar which would act as the base class for all my dockable windows.
Hence the first step was to convert my modeless CPropertySheet to a modeless CDialog. I just did this by creating a CDialog and placing the property sheet as a child window in it (and resizing when it resizes). This worked fine under Windows 2000/XP so I went ahead and changed the derived class from CDialog to (a class derived from) CDialogBar. With a lot of work it all worked fine under Windows 2000 and XP.
Then about a month later I discovered it fails miserably under Windows 95/98/ME.
I went back to my first step (property sheet in modeless CDialog) and even that fails under 9X. The call to CDialog::Create never returns. I stepped through the MFC code down to a call to API function CreateDialogIndirect which never returns. If I break I can see that there are various window messages being passed around (WM_SETCURSOR etc) but nothing ever gets drawn (obviously since CreateDialogIndirect never returns).
I think this is something that MFC is doing but I can't work it out. I also don't want to make major changes as I have spent a lot of time refining it as it is (under 2000).
What is going wrong here?
How do I fix it without major changes?
Why does Win9X behave differently to 2000/XP?
How can doing something so simple be so disastrous?