[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3483
  • Last Modified:

CDialog DoModal fails to instanciate dialog.

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
TrainMan
Asked:
TrainMan
  • 3
  • 2
1 Solution
 
TrainManAuthor Commented:
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
 
bertpCommented:
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
 
chensuCommented:
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.

 
TrainManAuthor Commented:
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
 
chensuCommented:
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
 
TrainManAuthor Commented:
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

Technology Partners: 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!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now