Solved

Application Plug-Ins

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
email obfuscation 4 16
calling procedure inside activexForm from secondform 1 232
Process Javascript errors with Delphi TWebBrowser 1 113
Delphi application Soap connection 5 96
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

920 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

16 Experts available now in Live!

Get 1:1 Help Now