Solved

Application Plug-Ins

Posted on 1997-09-20
3
177 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
Comment Utility
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
Comment Utility
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
Comment Utility
Code was a great help, Thanks JimBob.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now