Link to home
Start Free TrialLog in
Avatar of gwhite012597
gwhite012597

asked on

"Cannot assign a TFont to a TFont" error

Hi,

I've run into a problem while trying to create and add TTabsheet pages to a TPageControl from within a DLL.

aTabSheet := TTabSheet.Create(aPageControl);
aTabSheet.PageControl := aPageControl;

Now, creating the TabSheet seems to work fine. But when I assign the PageControl to the PageControl property of the TabSheet, I get a "Cannot assign a TFont to a TFont" error. Now this seems bizarre to me, as there's no mention of a TFont in any of my code. Could this be a bug in Delphi??

Anyway, if anyone has any idea as to what might be causing the problem, or how to solve it, I would really appreciate hearing from you.

Thanks
Greg
Avatar of nnbbb09
nnbbb09


Very strange. I've just tried the same code inside a dll and it works fine. Which version of Delphi are you using. I'm using D5 Pro. Do you have any event handlers attached to the pagecontrol or any of your tabsheets?

Jo
Avatar of gwhite012597

ASKER

I'm currently using Delphi4 but do have Delphi5 somewhere so I might give that a try. The funny thing is that I have had this working previously...
I am currently doing a re-write of a project, which, for this part anyway, is identical to what I am doing now. Even more frustrating is that I remember when I wrote the original version I had the same problem, but I don't remember how I managed to fix it.
Are you assigning the application object from your EXE to the DLL?

Cheers,

Raymond.
Not as far as I know...
I dynamically load the DLL using LoadLibrary, then call an exported function which instantiates an object from within the DLL. This object has a method called DrawPage which takes as an argument, the page control with which to add its pages to.

Basically, the idea is to have the main application loading one or more DLLs which each draw custom pages on the main form (by way of the PageControl). Hence creating a modular program.

Clear as mud??

Cheers,
Greg
ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Aha,

Your mention of using Packages has brought back my memory of what happened last time. I think (I'm not able to try it out at the moment) the solution that I found last time is to make sure the DLL is built with Runtime packages.

Thanks for jogging my memory... and I'll give passing it the TApplication a go aswell.

Cheers,

Greg
I have the same problem when I call a popupmenu.
How did you save the problem ?!
Thank´s a lot ?
The comments above illustrate the two ways: Pass the TApplication instance to the DLL, or compile both the application and the DLL with runtime packages enabled.

Cheers,

Raymond.