Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

CDialog DoModal fails to instanciate dialog.

Posted on 2000-04-15
6
Medium Priority
?
3,439 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 300 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

647 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