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
Ping Kam <pk...@quikcard.com> wrote in message news:3a104112$1_2@dnews...
>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
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
Igor, please trim your quotes to the bare minimum. Thanks.
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
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.
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)
>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.
>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)
Are you sure?
If so, why quote two full messages?
>Ok John, I get the point...
Hmmm... obviously not completely.