Board index » cppbuilder » Using VCL in a DLL called from MSVC

Using VCL in a DLL called from MSVC


2006-07-29 04:17:57 AM
cppbuilder101
Perhaps someone could either answer this, or suggest the correct group
for it.
I need to have an MSVC program call a DLL which provides a form using
Delphi VCL components (I'm writing in BDS2006 C++, although Delpi would
be an option!).
I've successfully created and displayed the form; however I can't
persuade it to close down properly.
This seems to have changed between BCB5/BCB6/BDS; has anyone mastered
it?
Mike
 
 

Re:Using VCL in a DLL called from MSVC

"Mike Goodey" < XXXX@XXXXX.COM >wrote in message
Quote
Perhaps someone could either answer this, or suggest the correct group
for it.

I need to have an MSVC program call a DLL which provides a form using
Delphi VCL components (I'm writing in BDS2006 C++, although Delpi would
be an option!).

I've successfully created and displayed the form; however I can't
persuade it to close down properly.

This seems to have changed between BCB5/BCB6/BDS; has anyone mastered
it?
Make sure the VCL DLL has its Application->Handle set properly. For more
information, see: tinyurl.com/9jzsa
- Dennis
 

Re:Using VCL in a DLL called from MSVC

Mike Goodey < XXXX@XXXXX.COM >wrote in
Quote
Perhaps someone could either answer this, or suggest the correct group
for it.

I need to have an MSVC program call a DLL which provides a form using
Delphi VCL components (I'm writing in BDS2006 C++, although Delpi would
be an option!).

I've successfully created and displayed the form; however I can't
persuade it to close down properly.

This seems to have changed between BCB5/BCB6/BDS; has anyone mastered
it?

Mike


IIRC, you need to set the Application->Handle value of your child (VCL)
window to a valid TApplication variable. If you're invoking it as a
simple form in a DLL, the close might fail because there is no valid
Application object. You might want to wrap your TForm invocation in the
DLL wrapper inside something that creates a new TApplication object
before opening the form.
Regards,
mr_organic
 

{smallsort}

Re:Using VCL in a DLL called from MSVC

Thanks Dennis and Mr Organic
Quote
Make sure the VCL DLL has its Application->Handle set properly.
Not as easy as it might sound, when the main program is MSVC!
What I AM doing is , shortly after the DLL startup I am calling
Application->Initialize();
which possibly does nothing... but I seem to remember something about
DLLs using a descendant of TApplication, though I can't find anything
about it any more.
More to the point, I've tried replacing the component I REALLY want
with TMemo - and this closes down properly.
So I need to look more closely at the component (TFrameViewer) that I
really want.
Mike
 

Re:Using VCL in a DLL called from MSVC

"Mike Goodey" < XXXX@XXXXX.COM >wrote in message
Quote
Thanks Dennis and Mr Organic

>Make sure the VCL DLL has its Application->Handle set properly.

Not as easy as it might sound, when the main program is MSVC!
Sure it is. Just set the DLL's Application->Handle to the handle of your VC
application's main window.
Quote
More to the point, I've tried replacing the component I REALLY want
with TMemo - and this closes down properly.

So I need to look more closely at the component (TFrameViewer) that I
really want.
Well, then that's yet another problem. Even so, you should still make sure
to set the VCL DLL's Application->Handle. Not doing so is sure to lead to
other bizarre behavior.
- Dennis