Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TFrame in dll

158 views
Skip to first unread message

Ping Kam

unread,
Nov 13, 2000, 3:00:00 AM11/13/00
to
Hi:

I have some problem using a dll function to create a frame in my test to
modulize my application in dlls. I though this should be very simple but
turns out to be not.

My test dll only exports one procedure and one function. The procedure is
use to set the application handle. The function creates and returns an
instance of TFrame.

function GetNewFrame(AOwner: TComponent): TFrame; stdcall; export;
begin
Result := TFrame.Create(AOwner);
end;

Very simple so far.

In my caller apps, I place a panel and a button. And on the button's
OnClick:

procedure TForm1.Button1Click(Sender: TObject);
var
AFrame: TFrame;
begin
SetAppHandle(Application.Handle); // Set the dll's application handle
AFrame := GetNewFrame(Panel1);
AFrame.Parent := Panel1; // I get exception EConvertError "cannot assign
a TFont to a TFont
end;

Trying to debug the problem, I add another panel and button to the main form
and on the button's Onclick:

procedure TForm2.Button1Click(Sender: TObject);
var
AFrame: TFrame;
begin
AFrame := TFrame.Create(Panel2);
AFrame.Parent := Panel2;
end;

This event handler works fine.

Although I don't think I need sharemem for it, I add it to both the dll and
my exe but it doesn't solve the problem.

I am running out of ideas. What am I missing, or creating a frame from a
dll is not recommended?

TIA,
Ping Kam

Ping Kam

unread,
Nov 13, 2000, 3:00:00 AM11/13/00
to
I forget to mention that I got an AV when I close my app.

Ping Kam

Ping Kam <pk...@quikcard.com> wrote in message news:3a104112$1_2@dnews...

Rudy Velthuis (TeamB)

unread,
Nov 13, 2000, 3:00:00 AM11/13/00
to
Ping Kam wrote...

>I forget to mention that I got an AV when I close my app.

Ping, next time also don't forget to trim your quotes, please.
--
Rudy Velthuis (TeamB) http://delphi-jedi.org

Use Borland servers; Posts via ISPs are not seen by TeamB
http://www.borland.com/newsgroups/genl_faqs.html

Igor Raskin

unread,
Nov 13, 2000, 3:00:00 AM11/13/00
to

Ping,

in order to integrate your dll so tightly into the main application you
need to compile both with runtime packages. The famous "Cannot
assign a TFont to a TFont" error is due to the fact that without runtime
packages there are two copies of VCL code in memory. One of these
TFont's comes from dll and the other - from the main app, therefore
they have different adresses of Virtual Method Tables - which is what
Delphi uses in "is" and "as" operators.

Igor

Rudy Velthuis (TeamB)

unread,
Nov 13, 2000, 3:00:00 AM11/13/00
to
Igor Raskin wrote...

Igor, please trim your quotes to the bare minimum. Thanks.

Ping Kam

unread,
Nov 13, 2000, 3:00:00 AM11/13/00
to
> Ping,
>
> in order to integrate your dll so tightly into the main application you
> need to compile both with runtime packages. The famous "Cannot
> assign a TFont to a TFont" error is due to the fact that without runtime
> packages there are two copies of VCL code in memory. One of these
> TFont's comes from dll and the other - from the main app, therefore
> they have different adresses of Virtual Method Tables - which is what
> Delphi uses in "is" and "as" operators.
>
> Igor
>
Thanks for you advice. With a little fight, I finally managed to build my
first package which exports my two simple procedures and load it dynamically
at run time.

The only drawback is now I must deploy the Delphi packages along with my own
packages, which I don't have to with dlls. It would be nice if Delphi let
me mix design time and run time packages in an executable.

Thanks,
Ping Kam

Oene Doevendans

unread,
Nov 15, 2000, 3:00:00 AM11/15/00
to
Rudy,

I think it is noble of you to try to get people to stick to the
"netiquette" as much as possible, but in my opinion it would be even
more noble when you send
these kind of messages to the "perpetrator" instead of sending it to the
newsgroups.
Personally, I have no interest in these kinds of messages (the list of
messages is long enough as it is....)

No offence intended, Doef.

"Rudy Velthuis (TeamB)" wrote:
>
> Ping Kam wrote...
>
> >I forget to mention that I got an AV when I close my app.
>
> Ping, next time also don't forget to trim your quotes, please.

Mike Orriss (TeamB)

unread,
Nov 15, 2000, 3:00:00 AM11/15/00
to
In article <3A126181...@fel.tno.nl>, Oene Doevendans wrote:
> Personally, I have no interest in these kinds of messages (the list of
> messages is long enough as it is....)
>

Without these visible reminders, the problem would get worse.

Please bear in mind that these are moderated newsgroups and messages tend
to arrive in order, making the excessive quoting which can occur on usenet
totally unneccesary.

Placing the reminders here instead of e-mail prevents others making the
same mistake.


Mike Orriss (TeamB & Developer Express)
(Unless stated otherwise, my replies relate to Delphi 5)
(No unsolicited e-mail replies please)


Rudy Velthuis (TeamB)

unread,
Nov 15, 2000, 3:00:00 AM11/15/00
to
Oene Doevendans wrote...

>I think it is noble of you to try to get people to stick to the
>"netiquette" as much as possible, but in my opinion it would be even
>more noble when you send
>these kind of messages to the "perpetrator" instead of sending it to the
>newsgroups.

I intentionally don't. I write them here, so everyone who sees it is
reminded not to do it.

Dr John Stockton

unread,
Nov 15, 2000, 3:00:00 AM11/15/00
to
JRS: In article <3A126181...@fel.tno.nl> of Wed, 15 Nov 2000
11:12:17 seen in news:borland.public.delphi.objectpascal, Oene
Doevendans <Doeve...@fel.tno.nl> wrote:

>I think it is noble of you to try to get people to stick to the
>"netiquette" as much as possible, but in my opinion it would be even
>more noble when you send
>these kind of messages to the "perpetrator" instead of sending it to the
>newsgroups.

>Personally, I have no interest in these kinds of messages (the list of
>messages is long enough as it is....)
>

>No offence intended, Doef.
>
>"Rudy Velthuis (TeamB)" wrote:

>>
>> Ping, next time also don't forget to trim your quotes, please.
>> --
>> Rudy
>>

>> Us
>> ht

Please trim what you quote. In particular, signatures. In many
systems, responses are easier to read if quoted in Usenet order.

No, it is much better to do it here, since each such article informs
many readers; moreover, many readers know that the perpetrator has been
informed.

You may not want to read such messages; but it is better to have your
needs addressed rather than your mere wishes.

--
© John Stockton, Surrey, UK. j...@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL: http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper 4-line sig. separator is as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)

Oene Doevendans

unread,
Nov 16, 2000, 3:00:00 AM11/16/00
to
Ok John, I get the point...

Mike Orriss (TeamB)

unread,
Nov 16, 2000, 3:00:00 AM11/16/00
to
In article <3A13A33C...@fel.tno.nl>, Oene Doevendans wrote:
> Ok John, I get the point...
>

Are you sure?

If so, why quote two full messages?

Rudy Velthuis (TeamB)

unread,
Nov 16, 2000, 3:00:00 AM11/16/00
to
Oene Doevendans wrote...

>Ok John, I get the point...

Hmmm... obviously not completely.

Oene Doevendans

unread,
Nov 20, 2000, 3:00:00 AM11/20/00
to
"Mike Orriss (TeamB)" wrote:
>
> In article <3A13A33C...@fel.tno.nl>, Oene Doevendans wrote:
> > Ok John, I get the point...
> >
>
> Are you sure?
>
> If so, why quote two full messages?
That's called humor Mike (or cynicism)....

Mike Orriss (TeamB)

unread,
Nov 20, 2000, 3:00:00 AM11/20/00
to
In article <3A191A4A...@fel.tno.nl>, Oene Doevendans wrote:
> That's called humor Mike (or cynicism)....
>
I call it waste of bandwidth.
0 new messages