Writing modules for an application

Posted on 2003-02-27
Medium Priority
Last Modified: 2010-04-04
I have written several modules (dll's) for my application, and so fare this have worked fine.

But I'm currently working on a dll that need to create lots of images, the main application need to send an object to the module. When Images are created I set the parent property to this object.

The problem is tha twhen I try to set parent I get an exception saying: Cannot assign a TFont to a TFont.
What is causing this error and what is the best way to avoid it?

Lokking forward to some comments on this...
Question by:Fuzzy_no

Expert Comment

ID: 8033512
is in your exe and dll uses ShareMem as first?
if you pass to dll strings or objects which contains strings, shareMem must be inclued in uses.
wbr, mo.

Author Comment

ID: 8033613
mocarts.. thanks for you're quick response.

I included ShareMem in the uses clause in both the DLL and the EXE file. I decalred it as the first unit.

But sadly this did'nt change anything, I still get the same error...


Expert Comment

ID: 8033661
can you provide some lines of code (esspecially that part where you assing Parent property (of what class?))?
what types of classes you are using?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Accepted Solution

mocarts earned 200 total points
ID: 8037291
Now I understand what causes this error..
You didn't compiled your DLL and EXE with runtime packages, yes? You must do this (and include Sharemem, too, since TFont uses strings) in order to have correct RTTI for objects.
When you compile your DLL and EXE without runtime packages Delphi *thinks" that EXE's TFont is different class to DLL's TFont.
If you don't want to compile with runtime packages then you can pass to dll only HBITMAP (or some HDC), generate images and return handle back to you EXE. in this case you even don't need to include ShareMem in uses as DLL don't use strings.
but runtime packages is preffered anyway since you'll use same units in dll and in exe. placing shared units in package will reduce you exe and dll size.

wbr, mo.

Expert Comment

ID: 9317040
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
LVL 10

Expert Comment

ID: 9981650
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to accept mocarts's answer
Please leave any comments here within the next seven days.


Merry Christmas and happy new year!

EE Cleanup Volunteer

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

616 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