views:

68

answers:

1

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:

  1. Start Delphi, Create a new package.
  2. Add a TFrame to your bpl
  3. Save and compile, you should now have a .bpl and a .dcp.
  4. Close all
  5. Create a new application
  6. In your project properties, turn on "Build with Runtime packages"
  7. Add your bpl to the runtime packages list.
  8. Include the directories of your bpl and dcp files in the search path
  9. Close your project properties
  10. Go to your Form1, add the unit with your TFrame to your uses.
  11. In the FormCreate event, create the TFrame and add it to your application
  12. 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
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