Prevent Delphi Component Icon Creation During Development

I created a custom TOuterControl control that is the parent of several TInnerControls.

Everything works fine, except that the IDE creates icons for each child TInnerControl (InnerControl1 and InnerControl2 in the screenshot). How to prevent the creation of IDE badges?

alt text

unit TestControl; interface Procedure Register; implementation Uses Classes, Controls, SysUtils, DesignEditors, DesignIntf, VCLEditors; Type TOuterControl = Class; TInnerControl = Class(TComponent) Protected FOuterControl : TOuterControl; function GetParentComponent: TComponent; Override; Function HasParent : Boolean; Override; procedure SetParentComponent (Value: TComponent); Override; End; TOuterControl = Class(TCustomControl) Protected FInnerControls : TList; Procedure Paint; Override; Public Constructor Create(AOwner : TComponent); Override; Procedure AddInnerControl(AInnerControl : TInnerControl); procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override; End; TOuterControlEditor = Class(TDefaultEditor) Public Procedure ExecuteVerb(Index : Integer); Override; Function GetVerb (Index : Integer) : String; Override; Function GetVerbCount : Integer; Override; End; procedure TOuterControl.AddInnerControl(AInnerControl: TInnerControl); begin AInnerControl.FOuterControl := Self;; FInnerControls.Add(AInnerControl); Invalidate; end; constructor TOuterControl.Create(AOwner: TComponent); begin inherited; FInnerControls := TList.Create; end; procedure TOuterControl.GetChildren(Proc: TGetChildProc; Root: TComponent); var I : Integer; begin inherited; For I := 0 To FInnerControls.Count - 1 Do Proc(FInnerControls[I]); end; procedure TOuterControl.Paint; begin inherited; Canvas.FillRect(ClientRect); Canvas.TextOut(0,0, Format('Inner Control Count = %d', [FInnerControls.Count])); end; function TInnerControl.GetParentComponent: TComponent; begin Result := FOuterControl; end; function TInnerControl.HasParent: Boolean; begin Result := True; end; procedure TInnerControl.SetParentComponent(Value: TComponent); begin If Value Is TOuterControl Then If FOuterControl <> Value Then Begin FOuterControl := TOuterControl(Value); FOuterControl.AddInnerControl(Self); End; end; procedure TOuterControlEditor.ExecuteVerb(Index: Integer); Var OuterControl : TOuterControl; InnerControl : TInnerControl; begin inherited; OuterControl := TOuterControl(Component); If Index = 0 Then Begin InnerControl := TInnerControl.Create(OuterControl.Owner); OuterControl.AddInnerControl(InnerControl); End; end; function TOuterControlEditor.GetVerb(Index: Integer): String; begin Result := 'Add Inner'; end; function TOuterControlEditor.GetVerbCount: Integer; begin Result := 1; end; Procedure Register; Begin RegisterComponents('AA', [TOuterControl]); RegisterComponentEditor(TOuterControl, TOuterControlEditor); End; Initialization Classes.RegisterClasses([TInnerControl]); end. 
+6
delphi custom-controls
source share
3 answers

You can prevent them from accessing the form by:

 RegisterNoIcon([TInnerControl]); 

More information about RegisterNoIcon can be found at http://docwiki.embarcadero.com/VCL/e/index.php/Classes.RegisterNoIcon

It is a little confusing to have classes with a name that ends with "Control", but these are not ordinary visual controls.

+7
source share

If the TInnerControl is intended to be used only inside the TOuterControl, then you should call SetSubComponent (True) during / after creating the TInnerControl.

+5
source share

When you create internal controls, you tell them that their owner is the form (owner of the external control). Therefore, the form draws them, just like it attracts all the other components that it owns. You probably want the external control to own the internal.

+4
source share

All Articles