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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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