Einzelnen Beitrag anzeigen

Dennis07

Registriert seit: 19. Sep 2011
Ort: Deutschland
485 Beiträge
 
Delphi 11 Alexandria
 
#15

AW: Änderungen im TFrame auf einem TForm verhindern.

  Alt 30. Apr 2019, 06:34
Könntest per Designtime-Package die dortigen Controls oder direkt die ganzen Frames beispielsweise verstecken.
Das könnte dir helfen, habe ich mal vor Jahren geschrieben:

Delphi-Quellcode:
unit uDesignerSelectionProtector;

//////////////////////////////////////
/// Designer Selection Protector ///
/// **************************** ///
/// (c) 2017 Dennis Göhlert a.o. ///
//////////////////////////////////////

interface

uses
  DesignIntf, DesignEditors,
  System.Classes,
  Vcl.Controls;

type
  TDesignerSelectionProtector = class(TSelectionEditor)
  private
    class procedure HideChildren(const ADesigner: IDesigner; const AControl: TWinControl); static;
    class procedure ViewChildren(const ADesigner: IDesigner; const AControl: TWinControl); static;
  private type
    TDesignerSelectionProc = procedure (const ADesigner: IDesigner; const AControl: TWinControl);

    TDesignerSelectionAction = record
      Verb: String;
      Proc: TDesignerSelectionProc;
    end;
  protected const
    FActions: array [0 .. 1] of TDesignerSelectionAction = (
      (
        Verb: 'Hide children';
        Proc: TDesignerSelectionProtector.HideChildren
      ), (
        Verb: 'View children';
        Proc: TDesignerSelectionProtector.ViewChildren
      )
    );
  public
    procedure ExecuteVerb(Index: Integer; const List: IDesignerSelections); override;
    function GetVerb(Index: Integer): String; override;
    function GetVerbCount: Integer; override;
  end;

  procedure Register;

implementation

procedure Register;
begin
  RegisterSelectionEditor(TWinControl, TDesignerSelectionProtector);
end;

{ TDesignerSelectionLocker }

procedure TDesignerSelectionProtector.ExecuteVerb(Index: Integer; const List: IDesignerSelections);
var
  LSelectionIndex: Integer;
  LSelection: TPersistent;
begin
  inherited;
  for LSelectionIndex := 0 to Pred(List.Count) do
  begin
    LSelection := List[LSelectionIndex];
    if LSelection is TWinControl then
    begin
      FActions[Index].Proc(Designer, LSelection as TWinControl);
    end;
  end;
  Designer.Modified;
end;

function TDesignerSelectionProtector.GetVerb(Index: Integer): String;
begin
  Result := FActions[Index].Verb;
end;

function TDesignerSelectionProtector.GetVerbCount: Integer;
begin
  Result := Length(FActions);
end;

class procedure TDesignerSelectionProtector.HideChildren(const ADesigner: IDesigner; const AControl: TWinControl);
var
  LIndex: Integer;
begin
  for LIndex := 0 to Pred(AControl.ControlCount) do
  begin
    AControl.Controls[LIndex].SetDesignVisible(False);
  end;
end;

class procedure TDesignerSelectionProtector.ViewChildren(const ADesigner: IDesigner; const AControl: TWinControl);
var
  LIndex: Integer;
begin
  for LIndex := 0 to Pred(AControl.ControlCount) do
  begin
    AControl.Controls[LIndex].SetDesignVisible(True);
  end;
end;

end.
Dennis

Geändert von Dennis07 (30. Apr 2019 um 16:33 Uhr)
  Mit Zitat antworten Zitat