Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Application Plug-Ins

Posted on 1997-09-20
3
188 Views
Last Modified: 2013-11-18
I am writing an application which allows the user to design electronic circuits. Each electronic component is a Delphi object, most of which are derived from TCustomControl.

I want to be able to make my application use 'Plug-Ins' so that I could develop new components and they would simply be detected by the main application and used as though part of the original app.
All objects are created dynamically, so there needs to be a way of informing the main app. of the new classes of object that are available in the plug-in.

Is it possible to do something like this? I know that Adobe manage it with Photoshop, but I'm developing this app on my own and I don't know where to start with this one.

All help will be greatly received.
0
Comment
Question by:paulcheet
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 200 total points
ID: 1345652
I once created a program which had a kind of Add-In feature.  These add-ins were DLLs, which could be written by 3rd party developers.  You need to be able to develop a way of making the main EXE file aware of each DLL.  I used the Windows registry to accomplish this (i.e. stored a list of DLL files).  Each new DLL would thus have to be added to the DLL list, and the next time the main app started it would be aware of any new DLLs.

My app worked roughly as follows:  (I used Delphi 3, but should work in Delphi 2 as well...)

Each DLL has at least one call, e.g:
procedure CreateSpecialControl(hWndOwner: THandle);

The main app, which has a list of DLLs (from registry, or whatever) can call this procedure as follows:

type
  // Declare prototype, which must be in every DLL.
  TSpecialProc = procedure(hWndOwner: Integer);

procedure TForm1.CallDllProc(DLLFilename: string);
var
  hLib: THandle;
  pProc: Pointer;
begin
  hLib := LoadLibrary(PChar(DLLFilename));
  if hLib > 0 then
  begin
    // Each DLL should have procedure CreateSpecialControl.
    pProc := GetProcAddress(hLib, 'CreateSpecialControl');
    if Assigned(pProc) then
      TSpecialProc(pProc)(Self.Handle);
  end;
end;

Each DLL would then implement CreateSpecialControl in whatever way it needed.  You will probably need extra parameters in CreateSpecialControl (as long as each DLL's declaration was exactly the same, and the prototype in the main app had the correct declaration).

If this isn't enough to go on, mail me at davekw@iafrica.com and I'll mail you a sample app with a couple of add-in DLLs.

Dave

0
 

Author Comment

by:paulcheet
ID: 1345653
That seems great, but would the DLL's also be able to contain things such as popup menus that are associated with the control, or would I need a way of creating these in the main App?
I have not written any DLL's in Delphi, and I'm not too sure about the scope of functions declared within it.
I suppose it would be easier if every control had an identical interface, but I can't be certain that will be the case.

Any Ideas?
0
 

Author Comment

by:paulcheet
ID: 1345654
Code was a great help, Thanks JimBob.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question