Solved

Dialog box in an extension dll

Posted on 1998-10-01
12
261 Views
Last Modified: 2013-11-20
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
Comment
Question by:tvandegr
  • 6
  • 3
  • 2
  • +1
12 Comments
 

Author Comment

by:tvandegr
Comment Utility
Edited text of question
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 100 total points
Comment Utility
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
 

Author Comment

by:tvandegr
Comment Utility
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
 

Author Comment

by:tvandegr
Comment Utility
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
 
LVL 11

Expert Comment

by:mikeblas
Comment Utility
"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
 

Author Comment

by:tvandegr
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Expert Comment

by:polimetla
Comment Utility
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
 

Expert Comment

by:umarama
Comment Utility
Add the following code to the beginning of your DLL function:
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));

0
 
LVL 11

Expert Comment

by:mikeblas
Comment Utility
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
 

Author Comment

by:tvandegr
Comment Utility
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
 

Expert Comment

by:umarama
Comment Utility
Read help for AFX_MANAGE_STATE(AfxGetStaticModuleState( ));

0
 

Author Comment

by:tvandegr
Comment Utility
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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now