BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Splitting Application into Packages

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Chris
Guest





PostPosted: Wed Sep 27, 2006 12:02 am    Post subject: Splitting Application into Packages Reply with quote



Hi

I keep reading about how a large application can be split up using dlls, but
that in BCB a runtime package should be used so that exported forms work
correctly (if I understand it correctly it has to do with TApplication).

I have googled for some time trying to find a simple example for BCB6 but I
cannot find anything so I wonder if anyone can point me in the right
direction or preferably to a link with a good example.

Because I haven't been able to find any resources I cannot quite figure how
they are meant to work, for example, if I have a package with a form class
TfrmSomeNewForm, in my app, when I dynamically load the package and show the
form, will that form be listed in the Screen->Forms collection? how would I
call member functions of the form, hopefully someone can shine some light on
the whole subject for me.

Thanks

Chris F
Back to top
Clayton Arends
Guest





PostPosted: Wed Sep 27, 2006 2:27 am    Post subject: Re: Splitting Application into Packages Reply with quote



This is the simplest example I can think of.

Package:
- Create a new package
- Edit project options
- Set "Usage Options" to "Runtime only"
- "Linker" tab: make sure "Use Dynamic RTL" is checked
- "Direcotories/Conditionals" tab: Configure output settings
such that the "Final output" and "BPI\LIB output" paths
are in your local directory "." (unless you want the files
to end up at $(BCB)\projects\...)
- Click "OK"
- Add a form to the package (eg. name it "PackageForm")
- Add PACKAGE to the form's declaration
- If you don't plan to use the global object created for
the form then remove that code
- Save and build

Application:
- Create a new application
- "Linker" tab: Check "Use Dynamic RTL"
- "Packages" tab: Check "Build with runtime packages"
- Add the package created above to the "Runtime Packages" list
- Click "OK"
- In Unit1.cpp add a #include to include the package's form
(eg. PackageForm.h)
- Add a button to the form
- In the button handler add the following code
TPackageForm* form = new TPackageForm(this);
form->Show();
- Save and build

Now, when you run the application and click the button the form from the
package should be shown. There is no need to explicitly load the BPL since
that is all handled for you by the VCL and Windows.

Quote:
will that form be listed in the Screen->Forms collection?

Yes

Quote:
how would I call member functions of the form

If you set it up like I've shown you above your application code won't care
where the form is located. You just use the form as if it were part of your
application's EXE. In fact, you can even use the
Application->CreateForm() way of constructing your form if that's what you'd
like to do.

HTH,
- Clayton
Back to top
Chris
Guest





PostPosted: Fri Sep 29, 2006 1:32 pm    Post subject: Re: Splitting Application into Packages Reply with quote



Hi Clayton

Thanks for the info which was a great help. What I actually wanted to
achieve was to dynamically load the package and show the form when the user
wanted to work with it rather than it being linked into my main app.

After reading your post and playing around a bit (and also reading a few
other posts which if memory serves may have been yours?) I have a working
solution. This works great using LoadPackage and GetProcAddress etc.

Just so that this is archived and for anyone else having problems, the thing
that took me the longest was getting past an "Invalid Pointer Operation"
error that I hit the very second I used loadpackage. Turned out that I had
set 'Use Dynamic RTL' to false by default, turning this back on (and of
course enabling 'Use Runtime Packages' and adding just VCL;RTL) made it all
work.

Anyway, thanks for your time and efforts, they were greatly appreciated.

Best regards

Chris F
"Clayton Arends" <nospam_claytonarends (AT) hotmail (DOT) com> wrote in message
news:45199b2c$1 (AT) newsgroups (DOT) borland.com...
Quote:
This is the simplest example I can think of.

Package:
- Create a new package
- Edit project options
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.