I am trying to load a tframe inside a delphi package (bpl) to be shown in my main app please give me code for both package and application.
+8
A:
Give a man a fish and he eats for a day, learn a man to fish and he eats his whole life. So no code for you :)
How you should do it:
- Start Delphi, Create a new package.
- Add a TFrame to your bpl
- Save and compile, you should now have a .bpl and a .dcp.
- Close all
- Create a new application
- In your project properties, turn on "Build with Runtime packages"
- Add your bpl to the runtime packages list.
- Include the directories of your bpl and dcp files in the search path
- Close your project properties
- Go to your Form1, add the unit with your TFrame to your uses.
- In the FormCreate event, create the TFrame and add it to your application
- Compile and run
Summary: Create a package (bpl) with your frames. In your application, add the bpl to your runtime packages list and then use the TFrames as you would normally do.
The_Fox
2010-10-22 07:21:19
You can also load the BPL dynamically at runtime using LoadPackage() instead of linking to the package at compile-time. You can then have the BPL export a function that returns a TFrame object and the app can access that function via GetProcAddress(). Or, the BPL can register its TFrame class type(s) with RegisterClass() and the app can then instantiate it/them using GetClass/FindClass() and either TApplication.CreateForm() or TCustomFrameClass.Create().
Remy Lebeau - TeamB
2010-10-22 20:49:21