Solved

"Cannot assign a TFont to a TFont" error

Posted on 2001-06-09
8
3,127 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:gwhite012597
8 Comments
 
LVL 3

Expert Comment

by:nnbbb09
ID: 6171260

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
0
 

Author Comment

by:gwhite012597
ID: 6172079
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.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 6172874
Are you assigning the application object from your EXE to the DLL?

Cheers,

Raymond.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:gwhite012597
ID: 6173068
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
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
ID: 6174304
I understand what you are doing. I think you need to be using a common TApplication object. One way to do this is to use VCL packages for both EXE and DLL, or you can place a method in your DLL to pass it the TApplication instance from your application to it...

Cheers,

Raymond.
0
 

Author Comment

by:gwhite012597
ID: 6175429
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
0
 

Expert Comment

by:mvsilva
ID: 6885198
I have the same problem when I call a popupmenu.
How did you save the problem ?!
Thank´s a lot ?
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 6886867
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.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
LAN or WAN ? 11 90
Why can't I create any project with my delphi EXE file? 6 24
Delphi inherited method 6 68
Performance of SQL statement 37 111
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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