Solved

CDialog::Create never returns when it contains a CPropertySheet

Posted on 2004-03-24
13
317 Views
Last Modified: 2013-11-20
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).

Some questions:

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?

0
Comment
Question by:aphillips
  • 4
  • 2
  • 2
  • +3
13 Comments
 
LVL 6

Expert Comment

by:joghurt
Comment Utility
- Aren't you reach some resource-size or control-count limit of Win9x? Try to remove large bitmaps and/or too many controls.
- Can you open this modeless property sheet (without CDialog) under Win9x?
- Can you open the property sheet using standard WinAPI functions?

Another option is if you have non-standard controls (e.g., other than buttons, edits, static texts), try to remove them one by one. They may call some functions that work differently under Win9x or doesn't work at all or you cannot call them under Win9x.
0
 
LVL 3

Author Comment

by:aphillips
Comment Utility
The property sheet worked fine under Windows 9X.  It appears that just putting it inside a CDialog has caused the problem.  I have tweaked a few other things which may have a bearing.  But as it was a while ago I can't remember exactly what I have done.

I know I should try to isolate the problem and maybe even post some code.  But this will take a fair bit of work to do and I was hoping someone would have seen this type of thing before.

And I just don't know why it works under 2000/XP but not 9X, and why MFC does not give some sort of assertion to tell me what I have done wrong.
0
 
LVL 6

Expert Comment

by:joghurt
Comment Utility
If you put in in a CDialog, the per-window number of controls is bigger than using it as a modeless property sheet so this still might be a reason.
0
 
LVL 3

Author Comment

by:aphillips
Comment Utility
No, I made the whole window just a child window of the dialog.  The dialog has no controls only this child window.  The property sheet has exactly the same pages and controls as when it worked.
0
 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
just a guess...check your dialog resource's property...is it in WS_CHILD?, if yes, change to WS_POPUP
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 4

Expert Comment

by:bkfirebird
Comment Utility
bundle your aplication with the required libraries .... mainly comctrl32.dll  ..... old versions of these libraries can cause problems sometimes
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
I used to use embedded CPropertySheets in the past, but I run into too many problems with them. Now I only use CTabCtrl's anymore. It's a bit harder to use a CTabCtrl the first time you do this, but one you get the method worked out, it's not more work than embedding a property sheet.
0
 
LVL 3

Author Comment

by:aphillips
Comment Utility
roshmon said:
> is it in WS_CHILD?, if yes, change to WS_POPUP

I have tried both.  However, the doc for CDialogBar says it should be WS_CHILD, which it currently is.

bkfirebird said:
> bundle your aplication with the required libraries .... mainly comctrl32.dll  ...

I will try.  (Haven't had time to yet.)  However, although it was reported by some else on Windows 98, I have reproduced it under Windows ME and other Windows 9X machines.  Seems unlikely they all have the same problem DLL(s), esp. as I have never had any other problems.

khkremer said:
> I used to use embedded CPropertySheets .... Now I only use CTabCtrl's ...

This is probably good advice.  I have done a lot with property sheets over the years and there are lots of gotchas.  But if you use a TabCtrl won't that make your dialog a real mess in the dialog editor with the controls for all the pages on top of each other?


One other piece of info.  Even though CreateDialogIndirect never returns, the window seems to be getting heaps of WM_GETDLGCODE messages sent to it, after WM_SETCURSOR message(s).  I saw this before but I now think this is significant.  Why all these messages unless the dialog thinks it is trying to process some user input events?  At that point there would not be any user input events as the window has not even appeared on the screen.

It looks like Windows is in some sort of loop sending WM_GETDLGCODE messages and hence nothing else happens for the dialog window.

I also finally managed to hook Spy++ up to the window.  (Its hard to do before the window appears on the screen.)  When Spy++ is monitoring messages for the window evrything works fine.

I am now thinking it is some sort of order of events problem.  This would explain the difference between Windows 9X and XP/2K.  But I don't understand why the WM_GETDLGCODE messages are being sent even before the window appears.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
With a CTabCtrl you still have individual controls that you create and manage one dialog at a time. It's really not that different than working with an embedded property sheet. You have to do a little more work to manage switching the tabs, but you save a lot of time working around these "gotchas".
0
 
LVL 3

Author Comment

by:aphillips
Comment Utility
I have rewritten the dialogs and property sheets to get rid of dependencies on WM_INITDIALOG and DDX.  (CDialog does not support these so I had been calling the functions myself.)

This seems to have fixed the problem, although I never tracked down exactly what was going wrong.  However, it seems that it was some sort of order of window events problem.  I suspect that Windows 9X and descendants vs NT and descendants vary in the order they send some messages and/or how handling of some messages creates other messages.

Thanks to all who posted comments.

0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
PAQed, with points refunded (400)

Computer101
E-E Admin
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 87
unable to delete all specified values regedit 38 149
Window placement 17 64
Making an alias 7 51
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now