Solved

Application Plug-Ins

Posted on 1997-09-20
3
189 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

763 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