Creating Components at runtime from DLL

I am building an application which has a pagecontrol on the main form. I want to modularize the program, so that each dll is responsible for drawing one or more pages.

I have the framework in place to load each dll and create the number of pages the dll requests.
What do I need to pass to the dll 'DrawPage' procedure to allow it to create controls on the page?? Should the dll create the page itself and return it??

Thanks in advance,
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The best approach is to compile both - EXE and DLL with runtime-package support. In this case you can do inside of the DLL code *all* what you usually do in EXE - create forms, components, allocate memory (especially strings) and other resources and so on.

As more elegant solution create custom package instead of ordinary DLL. Really, package is special case of DLL with built-in support of other language features like class inheritance and so on. Just create the package and put to it all modules you wish to separate. Load this package like DLL but use LoadPackage function instead of LoadLibrary.

You can still call GetProcAddress for value returned by LoadPackage. More usable solution is to declare some "common" package with global variable package to find entry point and some abstract base class. Package will creates instance of classes, derived from this abstract class and register them inside of initialization with the help of the global variable. This technique allows easy plugin-style application dividing.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gwhite012597Author Commented:
The runtime package support seems to be what was causing the problem. Thanks for the tip.

I have done a bit more work on it, and have decided to stick with the dll. Each module/dll will create a module object (when asked). This object will implement an interface which will detail all the function/procedures the main app will need.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.