• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

Dialog box in an extension dll

I am trying to create a dll that contains a class derived from CDialog.  Whenever I try to call DoModal() on the class I get an assertion.  It is failing in the DoDataExchange() call in CDialog::DoModal().  "No data exchange control with ID xxxx", in my case 1005, is the problem  I have tried including the resource.h file from the dll with no luck, renamed so it would not conflict with the resource.h from the calling project.  I am developing under NT with VC++ 5 sp3.  The dll contains MFC stuff and STL stuff.

Thanks
0
tvandegr
Asked:
tvandegr
  • 6
  • 3
  • 2
  • +1
1 Solution
 
tvandegrAuthor Commented:
Edited text of question
0
 
mikeblasCommented:
Is the error an assertion, or a debug trace message?  The text you quote sounds like it's a debug trace message. An assertion has a very different format.

The trace message means that you've called an MFC data exchange function (like DDX_Text(), for example, or any one of its friends) in the DoDataExchange() method of a CDialog-derived class. But the ID of the control you provided in the DDX_Text() call could not be found at runtime, and therefore the DDX call failed.

Is the assertion your hitting immediately following that TRACE statement in the MFC source code, or is it some other assertion?

B ekiM

0
 
tvandegrAuthor Commented:
What I quoted is the trace statement.  The assertion is an ASSERT(FALSE) right after it.  It comes after the DoDataExchange tries to get a handle to a control and the handle is returned NULL.  Yes, you are correct with what is going on.  What I need to know is how do I have all of the IDs used in creating the dll known to the dll at run time.

Thanks

tvandegr
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
tvandegrAuthor Commented:
What I quoted is the trace statement.  The assertion is an ASSERT(FALSE) right after it.  It comes after the DoDataExchange tries to get a handle to a control and the handle is returned NULL.  Yes, you are correct with what is going on.  What I need to know is how do I have all of the IDs used in creating the dll known to the dll at run time.

Thanks

tvandegr
0
 
mikeblasCommented:
"how do I have all of the IDs used in creating the DLL known to the DLL at runtime."

What are you asking? I can't parse that sentence.

Do you want to enumerate the child windows of a dialog?

B ekiM
0
 
tvandegrAuthor Commented:
Sorry.  That was a poor question and comment.  What I am trying to say is that when I do the DoModal() for the dialog box that is defined in my dll it gets the control ID (i.e. 1005) from the dll, then it tries to get a handle for that control by looking for it within the app that is including the dll, but no control is defined using that numer, so I get the assertion.  I need it to try to get the handle from the dll instead, or where ever the information for the controls in the dll are stored.  I hope this is a better explanation.

thanks,
tvandegr
0
 
polimetlaCommented:
Dear Brother/sister

I succussfully completed your task.
the answer is ready in my site.
please go and see.
http://members.tripod.com/~polimetla

Any doubts please let me know

with love,
Bhavani P Polimetla
Bhavani_73@hotmail.com

0
 
umaramaCommented:
Add the following code to the beginning of your DLL function:
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));

0
 
mikeblasCommented:
Sorry, you lost me again.  You say:  ".  What I am trying to say is that when I do the DoModal() for the dialog box that is defined in my dll it gets the control ID (i.e. 1005) from the dll," but dialog boxes don't have control IDs; only child windows have control IDs.

B ekiM
0
 
tvandegrAuthor Commented:
The control IDs are for controls on the Dialog box, in this case ListBoxs and Buttons.

I have tried adding the following code before any calls that use the resource IDs for the controls, for instance the DoDataExchange() method in my class to tell the dll to look internally and not in the application.  It did not seem to help.

HINSTANCE hInstResourceClient = AfxGetResourceHandle();
AfxSetResourceHandle(MY_DLL_NAMEDLL.hModule);
..
AfxSetResourceHandle(hInstResourceClient);

I was looking back and I do not think that I stated that this was an extension Dll, I do not know if this helps any.

Tom
0
 
umaramaCommented:
Read help for AFX_MANAGE_STATE(AfxGetStaticModuleState( ));

0
 
tvandegrAuthor Commented:
I believe that AFX_MANAGE_STATE(AfxGetStaticModuleState( )) is for regular DLLs and I am writing an extension DLL.  I use it before using MFC stuff in the Regular DLLs that I have written.  When I add it into this DLL and try to compile it complaines about DLLMain already being defined in a different file.  I do not have a single function that I am exporting that opens up a dialog box.  I am exporting a class that is derived from CDialog.

tvandegr
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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