From 5a8b53d7bf77aac8818bdddcc207834aa41b12df Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 4 Nov 2017 15:27:50 +0000 Subject: [PATCH] IDE: fixed example designnonlcl git-svn-id: trunk@56283 - --- designer/framedesigner.pas | 2 +- examples/designnonlcl/mywidgetdesigner.pas | 18 ++++++++++++++++++ ide/customformeditor.pp | 5 +++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/designer/framedesigner.pas b/designer/framedesigner.pas index 32b9d96dcd..8f06507062 100644 --- a/designer/framedesigner.pas +++ b/designer/framedesigner.pas @@ -120,7 +120,7 @@ end; procedure TFrameDesignerForm.Create; begin inherited Create; - // workaround problem with out assumption that Width = ClientWidth, Height = ClientHeight + // workaround problem with assumption that Width = ClientWidth, Height = ClientHeight NonFormProxyDesignerForm.AutoScroll := False; end; diff --git a/examples/designnonlcl/mywidgetdesigner.pas b/examples/designnonlcl/mywidgetdesigner.pas index c969db5b30..71ffc57382 100644 --- a/examples/designnonlcl/mywidgetdesigner.pas +++ b/examples/designnonlcl/mywidgetdesigner.pas @@ -42,6 +42,9 @@ type TMyWidgetMediator = class(TDesignerMediator,IMyWidgetDesigner) private FMyForm: TMyForm; + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); + override; public // needed by the Lazarus form editor class function CreateMediator(TheOwner, aForm: TComponent): TDesignerMediator; @@ -102,6 +105,20 @@ begin inherited Destroy; end; +procedure TMyWidgetMediator.Notification(AComponent: TComponent; + Operation: TOperation); +begin + inherited Notification(AComponent, Operation); + if Operation=opRemove then + begin + if FMyForm=AComponent then + begin + FMyForm.Designer:=nil; + FMyForm:=nil; + end; + end; +end; + class function TMyWidgetMediator.CreateMediator(TheOwner, aForm: TComponent ): TDesignerMediator; var @@ -110,6 +127,7 @@ begin Result:=inherited CreateMediator(TheOwner,aForm); Mediator:=TMyWidgetMediator(Result); Mediator.FMyForm:=aForm as TMyForm; + Mediator.FMyForm.FreeNotification(Mediator); Mediator.FMyForm.Designer:=Mediator; end; diff --git a/ide/customformeditor.pp b/ide/customformeditor.pp index 60a348d77f..0dd8a53aaf 100644 --- a/ide/customformeditor.pp +++ b/ide/customformeditor.pp @@ -86,7 +86,7 @@ type function OnPropHookGetAncestorInstProp(const InstProp: TInstProp; out AncestorInstProp: TInstProp): boolean; protected - FNonFormForms: TAvlTree; // tree of TNonControlDesignerForm sorted for LookupRoot + FNonFormForms: TAvlTree; // tree of TNonFormProxyDesignerForm sorted for LookupRoot procedure SetSelection(const ASelection: TPersistentSelectionList); procedure OnObjectInspectorModified(Sender: TObject); procedure SetObj_Inspector(AnObjectInspector: TObjectInspectorDlg); virtual; @@ -845,7 +845,8 @@ begin (Result as INonFormDesigner).LookupRoot := LookupRoot; FNonFormForms.Add(Result); - if Result is BaseFormEditor1.NonFormProxyDesignerForm[NonControlProxyDesignerFormId] then begin + if Result is BaseFormEditor1.NonFormProxyDesignerForm[NonControlProxyDesignerFormId] + then begin // create the mediator MediatorClass:=GetDesignerMediatorClass(TComponentClass(LookupRoot.ClassType)); if MediatorClass<>nil then