Главная страница | назад





Article #17625: Calling an MDI form in a DLL

 Question and Answer Database

FAQ2625C.txt   Calling an MDI form in a DLL
Category   :VCL
Platform    :All
Product    :C++Builder  3.x

Question:
How do I use an MDI forn in a DLL, when the MainForm is in the 
exe, and the MDIForm is found in the DLL?

Answer:
If you try to use a MainForm that is a MDIForm in an exe, and 
try to use a MDIChild form contained in the DLL, you will 
end up with an AV "No MDI forms are currently active".

Note:This workaround is not recomended due to problems
 arising because of setting the DLL Application object.  Go  here  for 
an alternate workaround.

What happens is when you try to show the child form, the VCL
checks if the Applications MainForm property is valid.  The AV
is thrown if the MainForm property is false.

The DLL also contains an Application object, and it's MainForm
property is checked.  The DLL's Application object doesn't
have a MainForm, so it will fail.

What you need to do is set the DLL's Application object to 
the Application object of the calling app (*This only works
if the calling app, is a VCL app).  Before the DLL unloads
you must set the DLL's Application Object back to it's 
original state, so memory clean up will work properly. 

To do this, you will need to store the Application object
in a Global variable.






7/2/98 10:32:32 AM
 

Last Modified: 28-FEB-00