unit MainFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, xpCore, xpPlugInMng;
type
{ TfrmMain }
TfrmMain =
class(TForm)
btnTest: TButton;
edtFirstName: TLabeledEdit;
edtLastName: TLabeledEdit;
mmoLog: TMemo;
PlugInManager: TxpPlugInManager;
procedure FormCreate(Sender: TObject);
procedure PlugInManagerLoadPlugIn(Sender: TObject; PlugIn: TxpPlugIn);
procedure PlugInManagerUnloadPlugIn(Sender: TObject; PlugIn: TxpPlugIn);
procedure btnTestClick(Sender: TObject);
private
{ Private-Deklarationen }
FLocalVar:
string;
procedure CallbackProc(ActionGUID:
string; CallbackInfo: Pointer);
public
{ Public-Deklarationen }
end;
var
frmMain: TfrmMain;
implementation
uses
SamplePlugInIntf;
{$R *.dfm}
{-------------------------------------------------------------------------------
Procedure: TfrmMain.FormCreate
Author: Marc Hoffmann
DateTime: 2009/12/10
Arguments: Sender: TObject
Result: None
-------------------------------------------------------------------------------}
procedure TfrmMain.FormCreate(Sender: TObject);
begin
FLocalVar := '
In der Wüste steht ein Reddisch - ferdisch 8-)';
end;
{-------------------------------------------------------------------------------
Procedure: TfrmMain.PlugInManagerLoadPlugIn
Author: Marc Hoffmann
DateTime: 2009/12/10
Arguments: Sender: TObject; PlugIn: TxpPlugIn
Result: None
-------------------------------------------------------------------------------}
procedure TfrmMain.PlugInManagerLoadPlugIn(Sender: TObject; PlugIn: TxpPlugIn);
begin
mmoLog.Lines.Add(Format('
PlugIn "%s" geladen...', [PlugIn.FileName]));
end;
{-------------------------------------------------------------------------------
Procedure: TfrmMain.PlugInManagerUnloadPlugIn
Author: Marc Hoffmann
DateTime: 2009/12/10
Arguments: Sender: TObject; PlugIn: TxpPlugIn
Result: None
-------------------------------------------------------------------------------}
procedure TfrmMain.PlugInManagerUnloadPlugIn(Sender: TObject; PlugIn: TxpPlugIn);
begin
mmoLog.Lines.Add(Format('
PlugIn "%s" entladen...', [PlugIn.FileName]));
end;
{-------------------------------------------------------------------------------
Procedure: TfrmMain.CallbackProc
Author: Marc Hoffmann
DateTime: 2009/12/10
Arguments: ActionGUID: string; CallbackInfo: Pointer
Result: None
-------------------------------------------------------------------------------}
procedure TfrmMain.CallbackProc(ActionGUID:
string; CallbackInfo: Pointer);
var
CallbackStruct: PCallbackStruct;
begin
ShowMessage('
B: ' + Self.FLocalVar);
CallbackStruct := CallbackInfo;
ShowMessage('
Callback called:' + #13#13 + Trim(CallbackStruct^.FirstName + #32 + CallbackStruct^.LastName));
end;
{-------------------------------------------------------------------------------
Procedure: TfrmMain.btnTestClick
Author: Marc Hoffmann
DateTime: 2009/12/10
Arguments: Sender: TObject
Result: None
-------------------------------------------------------------------------------}
procedure TfrmMain.btnTestClick(Sender: TObject);
var
SamplePlugIn: ISamplePlugIn;
begin
ShowMessage('
A: ' + FLocalVar);
if not(PlugInManager.LoadPlugIn('
SamplePlugIn', ISamplePlugIn, SamplePlugIn))
then
raise Exception.Create(PlugInManager.LastError);
try
SamplePlugIn.RegisterCallbackProc(CallbackProc);
SamplePlugIn.Execute(edtLastName.Text, edtFirstName.Text);
finally
PlugInManager.UnloadPlugIn(SamplePlugIn);
end;
end;
end.