Thema: Delphi Plugins selbst gemacht?

Einzelnen Beitrag anzeigen

MichaelK

Registriert seit: 8. Mai 2003
10 Beiträge
 
#10
  Alt 21. Mai 2003, 11:45
ich poste einfach mal die komplette DLL (ist noch nicht soo lange)

Code:
library Aboutplg;

uses
  ShareMem,
  SysUtils,
  Classes,
  Windows,
  Forms,
  PluginDef in '..\Shared\PluginDef.pas',
  frmPlugAbout in 'frmPlugAbout.pas' {AboutBox};

{$R *.res}

type
  TPluginAbout = class (TPlugIn)
  private
    FPicFilename, FProductname, FCopyright, FVersion, FComments: string;
  public
    constructor Create(aParent: THandle);
    procedure SubmitPicutre(Filename: string); override; stdcall;
    procedure SubmitProductname(Productname: string); override; stdcall;
    procedure SubmitVersion(Version: string); override; stdcall;
    procedure SubmitCopyright(Copyright: string); override; stdcall;
    procedure SubmitComments(Comments: string); override; stdcall;
    // information strings
    function GetName: string; override; stdcall;
    function GetAuthor: string; override; stdcall;
    function GetComment: string; override; stdcall;
    // menu data
    function GetMenuText: string; override; stdcall;
    function GetEnabled: Boolean; override; stdcall;
    // launch the Expert
    procedure Execute; override; stdcall;
    // event handler
    function EventHandler(EventNotification: TEventNotification): TEventAction;
        override; stdcall;
  end;

procedure TPluginAbout.SubmitPicutre(Filename: string); stdcall;
begin
  FPicFilename := Filename;
end;

procedure TPluginAbout.SubmitProductname(Productname: string); stdcall;
begin
  FProductname := Productname;
end;

procedure TPluginAbout.SubmitVersion(Version: string); stdcall;
begin
  FVersion := Version;
end;

procedure TPluginAbout.SubmitCopyright(Copyright: string); stdcall;
begin
  FCopyright := Copyright;
end;

procedure TPluginAbout.SubmitComments(Comments: string); stdcall;
begin
  FComments := Comments;
end;


constructor TPluginAbout.Create(aParent: THandle);
begin
  inherited Create(aParent);
  FProductname := 'Aboutplg.dll';
  FVersion := '1.0';
  FCopyright := 'Copyright(C) 2003 by Michael Kirches';
  FComments := 'This is a test plugin';
end;


// information strings
function TPluginAbout.GetName: string; stdcall;
begin
  result := 'About Plugin';
end;

function TPluginAbout.GetAuthor: string; stdcall;
begin
  result := 'Michael Kirches';
end;

function TPluginAbout.GetComment: string; stdcall;
begin
  result := 'This plugin creates and handles an aboutbox';
end;
// menu data
function TPluginAbout.GetMenuText: string; stdcall;
begin
  result := 'About';
end;

function TPluginAbout.GetEnabled: Boolean; stdcall;
begin
  result := True;
end;
// launch the Expert
procedure TPluginAbout.Execute; stdcall;
begin
//  MessageBox(Parent, 'This is Plugin No. 1 calling.','Info',0);
  //Now we've got something todo...
  try
    Aboutbox := TAboutbox.Create(Application);
    if FPicFilename <> '' then Aboutbox.ProgramIcon.Picture.LoadFromFile(FPicFilename);
    Aboutbox.ProductName.Caption := FProductname;
    Aboutbox.Version.Caption := FVersion;
    Aboutbox.Copyright.Caption := FCopyright;
    Aboutbox.Comments.Caption := FComments;
    Aboutbox.Rescale;
    Aboutbox.ShowModal;
  finally
    Aboutbox.Free;
  end;
end;
// event handler
function TPluginAbout.EventHandler(EventNotification: TEventNotification): TEventAction;
    stdcall;
begin
  result := evnContinue;
end;

function LoadPlugin(Parent: THandle; var PlugIn: TPlugIn): Boolean; export;
begin
  try
    PlugIn := TPluginAbout.Create(Parent);
    Result := True;
  except
    Result := False;
  end;
end;

exports
  LoadPlugIn name 'LoadPlugIn';

begin
end.
Da fehlt noch eine Prozedur, die dann die Aboutbox updaten soll, aber das kriege ich dann schon hin, wenn ich weiß, was ich falsch gemacht habe...

Ach ja: ShareMem ist in beiden Projekten die erste Unit in der uses-clause
  Mit Zitat antworten Zitat