117 lines
2.5 KiB
ObjectPascal
117 lines
2.5 KiB
ObjectPascal
unit uHostMainForm;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, uGUIBase, ExtCtrls, uCustomEditor, cxControls;
|
|
|
|
type
|
|
THostMainForm = class(TForm, IHostForm)
|
|
Panel1: TPanel;
|
|
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
|
procedure FormShow(Sender: TObject);
|
|
protected
|
|
FContenido : TCustomEditor;
|
|
function GetWorkPanel: TWinControl;
|
|
procedure OnWorkPanelChanged(AEditor : ICustomEditor);
|
|
procedure ShowEmbedded(AEditor : ICustomEditor);
|
|
procedure ReleaseEmbedded;
|
|
public
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
property WorkPanel: TWinControl read GetWorkPanel;
|
|
end;
|
|
|
|
var
|
|
HostMainForm: THostMainForm;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses
|
|
TestFramework, GUITestRunner, TextTestRunner;
|
|
|
|
|
|
{ TForm1 }
|
|
|
|
constructor THostMainForm.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
FContenido := NIL;
|
|
end;
|
|
|
|
destructor THostMainForm.Destroy;
|
|
begin
|
|
ReleaseEmbedded;
|
|
inherited;
|
|
end;
|
|
|
|
procedure THostMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
|
begin
|
|
CanClose := True;
|
|
if Assigned(FContenido) then
|
|
CanClose := FContenido.CloseQuery;
|
|
end;
|
|
|
|
procedure THostMainForm.FormShow(Sender: TObject);
|
|
begin
|
|
if IsConsole then
|
|
TextTestRunner.RunRegisteredTests
|
|
else
|
|
GUITestRunner.RunRegisteredTestsModeless;
|
|
Self.SendToBack;
|
|
end;
|
|
|
|
function THostMainForm.GetWorkPanel: TWinControl;
|
|
begin
|
|
Result := Panel1;
|
|
end;
|
|
|
|
procedure THostMainForm.OnWorkPanelChanged(AEditor: ICustomEditor);
|
|
begin
|
|
//
|
|
end;
|
|
|
|
procedure THostMainForm.ReleaseEmbedded;
|
|
begin
|
|
if Assigned(FContenido) then
|
|
FContenido.Release;
|
|
Application.ProcessMessages;
|
|
end;
|
|
|
|
procedure THostMainForm.ShowEmbedded(AEditor: ICustomEditor);
|
|
begin
|
|
if Assigned(FContenido) then
|
|
if not FContenido.CloseQuery then
|
|
begin
|
|
AEditor.Release;
|
|
AEditor := NIL;
|
|
Exit;
|
|
end;
|
|
|
|
ShowHourglassCursor;
|
|
LockWindowUpdate(Handle);
|
|
try
|
|
FContenido := AEditor.GetInstance as TCustomEditor;
|
|
with (FContenido) do
|
|
begin
|
|
Visible := False;
|
|
BorderIcons := [];
|
|
BorderStyle := bsNone;
|
|
Parent := WorkPanel;
|
|
FContenido.Show;
|
|
Align := alClient;
|
|
FContenido.SetFocus;
|
|
end;
|
|
finally
|
|
Application.ProcessMessages;
|
|
LockWindowUpdate(0);
|
|
HideHourglassCursor;
|
|
end;
|
|
OnWorkPanelChanged(FContenido);
|
|
end;
|
|
|
|
end.
|