Solved

CDialog::Create never returns when it contains a CPropertySheet

Posted on 2004-03-24
13
324 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
ID: 10675210
- 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
ID: 10676423
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
ID: 10677466
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 3

Author Comment

by:aphillips
ID: 10684882
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
ID: 10839256
just a guess...check your dialog resource's property...is it in WS_CHILD?, if yes, change to WS_POPUP
0
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10839409
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
ID: 10843903
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
ID: 10855973
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
ID: 10855990
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
ID: 10983911
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
ID: 12037919
PAQed, with points refunded (400)

Computer101
E-E Admin
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 136
ORA-01403: no data found 43 101
only14 challenge 19 76
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 552
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

773 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