Solved

CDialog DoModal fails to instanciate dialog.

Posted on 2000-04-15
6
3,313 Views
Last Modified: 2013-11-20
I'm using Visual Studio V6 in Win98.

My dialog template is very basic I think.
     6 Text Boxes
     3 Progrsss Bars
     1 button = IDOK

The support class was constructed with the Wizzard.
Program compiles and links perfectly.

When the program runs and I select the menu item for this dialog the DoModal fails, retun = -1.

The calling code is as follows.
void CMainFrame::OnSlctEvalSummary()
{
     // Display the Self Appraisal Summary Results Dialog.
     CAppraisalResultsDlg  appraisalResults;
     int iReturnVal = appraisalResults.DoModal();
}

I traced into the failure with these results.

int CDialog::DoModal()
{
   TRY{
     AfxHookWindowCreat(this);
          // this = 0x0066f6d0{CAppraisalResultsDlg hWnd = 0x000000}
     if(CreateDlgIndirect(lpDialogTemplete,
          // lpDialogTemplete = 0x0042f580
        CWnd::FromHandle(hWndParent),
          // hWndParent = 0x00000574
        hInst))
          // hInst = 0x00400000

}

Here inside the TRY of the DoModal function at the 'if' is where it fails.  I can't find
documentation on the CreateDlgIndirect function and the above values appear to me as valid.

What can cause this failure?
Any ideas will be greatly appriciated.

Thanks in advance.
0
Comment
Question by:TrainMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Author Comment

by:TrainMan
ID: 2719381
Here's a thought.  Could this problem be cause by the CProgressCtrl class if it were not setup right?

When I first used this I was asked to select 3 options.  One was for Control, another for Ole, and the third I don't remember.  I de-select the last 2.

How can I change this?
0
 

Expert Comment

by:bertp
ID: 2719727
make sure you have rebuilt everything so that all is in sync with your class definition. my best guess  
is your resources, precompiled headers, and dialogbox implememtation are out of snyc and tripping up the CreateDlgIndirect function
 
If it still blows, see if your dialog processes the initdialog message

To make sure that the problem is the dialog box and not the program calling it, temporarily replace CAppraisalResultsDlg   with CAboutDlg to see if it can load the about dialog at that point...

HTH! Good luck debugging!

0
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 2719766
Put the following code in your application object's InitInstance function.

INITCOMMONCONTROLSEX InitCtrls =
{
    sizeof(INITCOMMONCONTROLSEX),
    ICC_PROGRESS_CLASS
};
::InitCommonControlsEx(&InitCtrls);
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:TrainMan
ID: 2727093
Thanks chensu for the input.  Haven't had the chance to try it and will not until maybe Wednesday night because of school and work.  
What does it do?

I did notice that by trying bertp's suggestion that the problem was in my template.  So I removed the 3 Progress Bars and the 2 MS Forms Labels, and everything worked fine.

When I tried to place a Forms Label in I had the same problem.  Then I tried placing just 1 Progress Bar in and got an assertion in my OnIninitDialog() function at SetRange().

So, what gives?
Do I need to enter similar code for that also?

Thanks in advance.
0
 
LVL 23

Expert Comment

by:chensu
ID: 2727457
The InitCommonControlsEx function initializes the Common Control library.

In order for the MS Forms Label ActiveX controls to work, you need to call the AfxEnableControlContainer function as well.
0
 

Author Comment

by:TrainMan
ID: 2738260
The problem with the CProgressCtrl was that the SetRange() and SetPos() functions got entered _prior_ to the call for CDialog::OnInitDialog().  Kinda dumb to try to use a pointer to an object that doesn't exists yet isn't it.  So I didn't need your first code fragment.

However the call to AfxEnableControlContainer() did need to be added to my apps InitInstance() function.

Thanks again for your help.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 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