uses
uDllFormInterfaces,
uDllForm,
Windows;
type
TDllFormWrapper =
class(TInterfacedObject, IDllForm)
private
fForm: TDllForm;
protected
function get_Caption: WideString;
stdcall;
function get_Item(aIndex: Integer): WideString;
stdcall;
procedure set_Caption(
const value: WideString);
stdcall;
procedure set_Item(aIndex: Integer;
const value: WideString);
stdcall;
property Form : TDllForm
read fForm;
function get_Handle: HWnd;
stdcall;
public
function AddLine(
const line: WideString): Integer;
stdcall;
property Caption : WideString
read get_Caption
write set_Caption;
property Item[aIndex : Integer] : WideString
read get_Item
write set_Item;
property Handle : HWnd
read get_Handle;
constructor Create;
destructor Destroy;
override;
procedure Hide;
stdcall;
procedure Show;
stdcall;
function ShowDialog : Integer;
stdcall;
end;
function CreateDllForm : IDllForm;
stdcall;
implementation
uses
Dialogs;
function CreateDllForm : IDllForm;
begin
result := TDllFormWrapper.Create();
end;
{ TDllFormWrapper }
constructor TDllFormWrapper.Create;
begin
inherited;
fForm := TDllForm.Create(
nil);
end;
destructor TDllFormWrapper.Destroy;
begin
fForm.Free();
ShowMessage('
freed!');
// weil manche nicht an RefCounting glauben ;-)
inherited;
end;
function TDllFormWrapper.AddLine(
const line: WideString): Integer;
begin
result := Form.ListBox1.Items.Add(line);
end;
function TDllFormWrapper.get_Caption: WideString;
begin
result := Form.Caption;
end;
function TDllFormWrapper.get_Item(aIndex: Integer): WideString;
begin
result := Form.ListBox1.Items[aIndex];
end;
procedure TDllFormWrapper.set_Caption(
const value: WideString);
begin
Form.Caption := value;
end;
procedure TDllFormWrapper.set_Item(aIndex: Integer;
const value: WideString);
begin
Form.ListBox1.Items[aIndex] := value;
end;
procedure TDllFormWrapper.Hide;
begin
Form.Hide();
end;
procedure TDllFormWrapper.Show;
begin
Form.Show();
end;
function TDllFormWrapper.ShowDialog : Integer;
begin
result := Form.ShowModal();
end;
function TDllFormWrapper.get_Handle: HWnd;
begin
result := Form.Handle;
end;