Board index » delphi » Changing ownership of controls in DLLs

Changing ownership of controls in DLLs

Hi there!

Say I have a form, in a DLL, which owns a TPanel with a TPageControl on it.
I
want to transfert the TTabSheets from the DLL to another PageControl from
my application. I call an exported function, passing it the target
PageControl,
and then set the PageControl property of the tabsheet...

Well, this works just fine when the source and target pagecontrol are
standard
forms in an application. But because the source form is in a DLL, i get the
following error: Can't assign a TFont to a TFont!

When, you get the drift of what I wanna do... It's not the
pagecontrol/tabsheet
combo, you get the same error with a simple button...

Any ideas?

Regards,

Remy.Gend...@Berclain.com
Please also forward a direct e-mail of the response...

 

Re:Changing ownership of controls in DLLs


Quote
Remy Gendron wrote:

> Say I have a form, in a DLL, which owns a TPanel with a TPageControl on it. I
> want to transfert the TTabSheets from the DLL to another PageControl from
> my application. I call an exported function, passing it the target PageControl,
> and then set the PageControl property of the tabsheet...

> Well, this works just fine when the source and target pagecontrol are standard
> forms in an application. But because the source form is in a DLL, i get the
> following error: Can't assign a TFont to a TFont!

This is has two solutions:
1. Don't.
2. Wait for D3.

The problem is that the RTTI is specific for each module. What happens
is that the pointer to the VMT (virtual method table) is used to
identify
a class. Since the DLL could be used in a VB application, the DLL has to
create a VMT for TFont in the DLL. Unfortunately, this also happens in
the
EXE. Obviously, the VMT pointer in the DLL isn't the same as the one in
the
EXE, and you get the strange Cannot assign a TFont to a TFont.
Delphi 3 will have a solution to this, I've heard.

There's actually two ways to accomplish what you want. The first is to
create
the TTabSheet in the DLL instead of in the EXE. I don't know how you
create
it in the first place, so I don't know how easy this would be.

The other solutin is to create a TForm instead of a TTabSheet in the
EXE, then
using SetParent/SetWindowWord/SetWindowLong on an _empty_ TTabSheet
created
in the DLL to make the TForm a child of the TTabSheet. This should work,
I'm using this techinique to have MDI children in a DLL.

M.

--
Ettertraktet kaffe, er det ekstra god kaffe?

mailto:martin.lars...@delfi-data.msmail.telemax.no
http://www.delfidata.no/users/~martin

Other Threads