unit AddonDllForm;

interface
uses  Windows, Controls, Classes, Forms,
			M2AddonImp, DllForm;

type
	TM2AddonForm = class(TDllForm)
	private
		FAddon: TM2CustomAddon;
	public
		constructor Create(AOwner: TComponent); override;
		destructor Destroy; override;
	end;

	procedure SetAddonForDllForms(anAddon: TM2CustomAddon);

implementation

var
	gAddon: TM2CustomAddon = nil;


procedure SetAddonForDllForms(anAddon: TM2CustomAddon);
begin
	gAddon := anAddon;
end;

{ TM2AddonForm }

constructor TM2AddonForm.Create(AOwner: TComponent);
begin
	inherited Create(AOwner);
	FAddon := gAddon;
	if Assigned(FAddon) then
		FAddon.AddForm(Self);
end;

destructor TM2AddonForm.Destroy;
begin
	if Assigned(FAddon) then
		FAddon.RemoveForm(Self);
	inherited Destroy;
end;


end.
