examples: objectinspector: fixed GetOwner

git-svn-id: trunk@49953 -
This commit is contained in:
mattias 2015-10-06 10:11:38 +00:00
parent 10280e3488
commit d962160e3f
2 changed files with 15 additions and 10 deletions

View File

@ -6,7 +6,7 @@ interface
uses uses
Classes, SysUtils, TypInfo, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, TypInfo, LResources, Forms, Controls, Graphics, Dialogs,
ObjectInspector, PropEdits, StdCtrls, Buttons; ObjectInspector, PropEdits, PropEditUtils, StdCtrls, Buttons;
type type
{ TMyComponent } { TMyComponent }
@ -20,6 +20,8 @@ type
property AnInteger: integer read FAnInteger write SetAnInteger; property AnInteger: integer read FAnInteger write SetAnInteger;
end; end;
{ TForm1 }
TForm1 = class(TForm) TForm1 = class(TForm)
PropGridGroupbox: TGroupBox; PropGridGroupbox: TGroupBox;
SetCompAsOIRootButton: TButton; SetCompAsOIRootButton: TButton;
@ -32,6 +34,8 @@ type
procedure SetCompAsOIRootButtonClick(Sender: TObject); procedure SetCompAsOIRootButtonClick(Sender: TObject);
private private
procedure SetObjectInspectorRoot(AComponent: TComponent); procedure SetObjectInspectorRoot(AComponent: TComponent);
protected
function GetOwner: TPersistent; override;
public public
TheObjectInspector: TObjectInspectorDlg; TheObjectInspector: TObjectInspectorDlg;
ThePropertyEditorHook: TPropertyEditorHook; ThePropertyEditorHook: TPropertyEditorHook;
@ -48,8 +52,8 @@ implementation
procedure TForm1.Form1Create(Sender: TObject); procedure TForm1.Form1Create(Sender: TObject);
begin begin
// create the PropertyEditorHook (the interface to the properties) // create the PropertyEditorHook (the interface to the properties)
ThePropertyEditorHook:=TPropertyEditorHook.Create; ThePropertyEditorHook:=TPropertyEditorHook.Create(nil);
// create the ObjectInspector // create the ObjectInspector
TheObjectInspector:=TObjectInspectorDlg.Create(Application); TheObjectInspector:=TObjectInspectorDlg.Create(Application);
TheObjectInspector.PropertyEditorHook:=ThePropertyEditorHook; TheObjectInspector.PropertyEditorHook:=ThePropertyEditorHook;
@ -105,6 +109,13 @@ begin
Selection.Free; Selection.Free;
end; end;
function TForm1.GetOwner: TPersistent;
begin
// this form is the LookupRoot => GetOwner must be nil
// see GetLookupRootForComponent
Result:=nil;
end;
{ TMyComponent } { TMyComponent }
procedure TMyComponent.SetAnInteger(const AValue: integer); procedure TMyComponent.SetAnInteger(const AValue: integer);

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="9"/> <Version Value="9"/>
@ -50,11 +50,5 @@
<CompilerOptions> <CompilerOptions>
<Version Value="11"/> <Version Value="11"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions> </CompilerOptions>
</CONFIG> </CONFIG>