Article View: borland.public.cppbuilder.nativeapi
Article #15452Re: How to use LoadPackage in BCB ?
From: Miem Chan
Date: Sat, 28 Jun 2003 12:16
Date: Sat, 28 Jun 2003 12:16
116 lines
4909 bytes
4909 bytes
Dear Clayton,
TTT
T
THANK YOU VERY MUCH!...for the examples...
Dynamic package loading in BCB is not a mystery anymore.
Examples and the way how you explain and highlight the important parts were
very good.
I think these examples (may be with a bit more text) should put in to
Borland developer website so that every body can learn from them.
I've copied the examples and tested both successfuly.
There were few small points I would like to add;
(1) In the both examples, the PACKAGE macro was not recognized without
including #include <System.hpp> line
//-----------------------------------------------------------------------
// PackageUnit1.h
#ifndef PackageUnit1H
#define PackageUnit1H
#include <System.hpp> //<--- This line added for the PACKAGE macro
extern "C" String PACKAGE __stdcall GetSomeText();
#endif
//-----------------------------------------------------------------------
(2) In the second examples, I had to add the BaseClass.cpp to the Project1,
otherwise it complains with the following two Linker Error messages
"Unsolved externals 'TBaseClass() referenced from the MAINFORM.OBJ"
"Unsolved externals '_CreateBaseClass_FunctionName' referenced from the
MAINFORM.OBJ"
Adding the BaseClass.cpp solves the problem.
(3) It is important to make sure that in the project options for the
Project1, the Linker/ Use Dynamic RTL is selected.
I would like to ask few more questions;
( i ) Is it okay to unload the package in FormDestroy method in the main
app. instead of in the destructor?
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
if (fPackageModule) {
UnloadPackage(reinterpret_cast <unsigned> (fPackageModule));
fPackageModule = 0;
}
}
(ii) How to use InitializePackage and define the corresponding
initialization code?
(iii) How to define "interface" in BCB ?
type
IMyCustomCalls = interface
['{D2945EC7-17C4-446F-9DF0-012069D07CC6}']
procedure MyCustomCall;
end;
(iv) How to use GetPackageInfo ?
(v) By adding the following RC file (MyRC.rc) I think it is possible to
add bitmap resources to the package.
If it were the DLL instead of package we would use LoadImage. BUT how to
load these bitmap resources (or any other resource) from the package in the
main app.?
// Resource.h
#ifndef MINIMAL_RCH
#define MINIMAL_RCH
#define IDB_BITMAP1 108
#define IDB_BITMAP2 109
#endif
// MyRC.rc
#include "resource.h"
IDB_BITMAP1 BITMAP DISCARDABLE "Bitmap1.bmp"
IDB_BITMAP2 BITMAP DISCARDABLE "Bitmap2.bmp"
( vi ) Would some one comment on the differences between packages and DLLs
?
When/why to use package and when/why DLL ?
Once again I would like to THANK YOU VERY MUCH for the examples..
Miem Chan
miemchan@yahoo.com
> > I read some of the recent postings in the group and searched the Google
> > (without any luck) to find an example BCB code showing how to use
dynamic
> > package loading.
>
> I found them in the past but must admit that I am finding those examples
> rather scarce. It looks like most of the working examples can be found in
> Delphi but not C++Builder.
>
> > Can some BCB guru donate a simple example code showing how to create a
> > package to export a form and how to make a main application to load the
> > exported form from the package dynamically?
>
> I will reply to this message with two examples that I can think of (and
> use). I'm sure there are some more tricky examples out there but this
> should hopefully be enough to get someone started.
>
> - Clayton
Technical Details
Message-ID:
<3efd9295@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3ef2a233@newsgroups.borland.com> <3ef2aa44$1@newsgroups.borland.com> <3ef5c77e@newsgroups.borland.com> <3ef7a17a$1@newsgroups.borland.com> <3efb1fd9@newsgroups.borland.com> <3efc97c1$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,2a0bcef6d2779e50 X-Google-Attributes: gid10cc67,public X-Google-Thread: 102541,2a0bcef6d2779e50 X-Google-Attributes: gid102541,public X-Google-ArrivalTime: 2003-06-28 06:09:02 PST From: "Miem Chan" <miemchan@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi,borland.public.cppbuilder.students References: <3ef2a233@newsgroups.borland.com> <3ef2aa44$1@newsgroups.borland.com> <3ef5c77e@newsgroups.borland.com> <3ef7a17a$1@newsgroups.borland.com> <3efb1fd9@newsgroups.borland.com> <3efc97c1$1@newsgroups.borland.com> Subject: Re: How to use LoadPackage in BCB ? Date: Sat, 28 Jun 2003 22:16:17 +1000 Lines: 120 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 210.50.16.62 Message-ID: <3efd9295@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1056805525 210.50.16.62 (28 Jun 2003 06:05:25 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail