Dialogs fail in debug mode

  • Thread starter Thread starter Seko
  • Start date Start date
S

Seko

Hi!

This is my first post here, so please excuse me for any mistakes I make.

---------------------

I'm having a hard time displaying modal/non-modal dialog boxes in a Windows
Forms Application project, because of the following problem:

If building a project in debug mode, I get a Debug Assertion when doing a
myDialog.DoModal() call, seemingly because a valid parent window handle for
the dialog cannot be found.
I've debugged the application, and found that a call to
AfxGetResourceHandle() triggers the assertion.

When building the same project with debugging disabled (in Release mode), no
exceptions are thrown, and the application runs flawlessly.

This is how I use the dialog (which has a class added, and extends from
CDialog):

CMyDialog theDialog;
theDialog.DoModal();

I've tried this too: CMyDialog theDialog(AfxGetMainWnd());
, but the error is the same.

(I'm using Visual C++ .NET 2003 Standard)

Any help would GREATLY be appreciated!

Thank you in advance,
-David
 
This is how I use the dialog (which has a class added, and extends from
CDialog):

CMyDialog theDialog;
theDialog.DoModal();

I've tried this too: CMyDialog theDialog(AfxGetMainWnd());
, but the error is the same.

David,

Where in your application do you invoke the dialog?

From what you say, I'd guess that you're trying to invoke the dialog
before aspects of the application are initialised.

Dave Lowndes
 
I try to invoke it when pressing a button, like so:
private: System::Void button2_Click(System::Object * sender,
System::EventArgs * e)

{
CMyDialog theDialog;
theDialog.DoModal();
}
 
David,

Where in your application do you invoke the dialog?

From what you say, I'd guess that you're trying to invoke the dialog
before aspects of the application are initialised.

Dave Lowndes

I try to invoke it when pressing a button, like so:
private: System::Void button2_Click(System::Object * sender,
System::EventArgs * e)

{
CMyDialog theDialog;
theDialog.DoModal();
}
 
I try to invoke it when pressing a button, like so:
private: System::Void button2_Click(System::Object * sender,
System::EventArgs * e)

{
CMyDialog theDialog;
theDialog.DoModal();
}
 
I try to invoke it when pressing a button, like so:

Have you somehow got a mix of MFC and managed .Net code in your
project - things don't seem consistent in what you've mentioned.

Dave
 
I'm just trying to show a simple dialog from a managed application - it
can't be that hard! :-)

What's the non-mixed mode of implementing dialog controls, then?

Btw, using an MFC DLL with a dialog resource in it worked correctly; it's
just this application that can't display its own dialog resources...
 
I'm just trying to show a simple dialog from a managed application - it
can't be that hard! :-)

Mixing MFC with managed code isn't supported as far as I know until
VS2005 is available. It's not something I've attempted to do anyhow.

Dave
 
Back
Top