⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createdesignereditor.pas

📁 类似Delphi Ide的对象查看器 可以在RUNTIME时使用
💻 PAS
字号:
unit CreateDesignerEditor;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, MyPanel, MyRadGrp, StdCtrls, MyButton, MyLstBox,
  CreateDesigner, MyAutoBtn;

type
  Tfrm_createdesignerEditor = class(TForm)
    btnCancel: TMyAutoBitBtn;
    btnOk: TMyAutoBitBtn;
    btnClear: TMyAutoBitBtn;
    rgControls: TMyRadioGroup;
    lstProtected: TMyListBox;
    btnAdd: TMyAutoBitBtn;
    btnDelete: TMyAutoBitBtn;
    lstLocked: TMyListBox;
    lstTransParent: TMyListBox;
    procedure FormCreate(Sender: TObject);
    procedure btnAddClick(Sender: TObject);
    procedure btnDeleteClick(Sender: TObject);
    procedure btnClearClick(Sender: TObject);
    procedure rgControlsClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure lstProtectedClick(Sender: TObject);
  private
    procedure UpdateButtons;
    procedure UpdateLists;
    function ActiveList: TMyListBox;
    procedure FillList(AOwner: TComponent; ListType: TListType; Target: TStrings; Exclude: TStrings; AName: string);
  public
    FormDesigner: TCustomFormDesigner;
    constructor Create(AOwner: TComponent); override;
  published
  end;

function EditLists(AFormDesigner: TCustomFormDesigner; DefaultList: TListType): Boolean;

{var
  frm_createdesignerEditor: Tfrm_createdesignerEditor;}

implementation

{$R *.dfm}

uses CreateAdd;

function EditLists(AFormDesigner: TCustomFormDesigner; DefaultList: TListType): Boolean;
begin
  with Tfrm_createdesignerEditor.Create(Application) do
  try
    FormDesigner:=AFormDesigner;
    if Assigned(FormDesigner) then
    begin
      Caption:=FormDesigner.Name;
      if Assigned(FormDesigner.Owner) then Caption:=FormDesigner.Owner.Name+'.'+Caption;
      rgControls.ItemIndex:=Integer(DefaultList);
      lstTransparent.Items.Assign(FormDesigner.TransparentControls);
      {$IFDEF TFD1COMPATIBLE}
      lstLocked.Items.Assign(FormDesigner.FixedControls);
      {$ELSE}
      lstLocked.Items.Assign(FormDesigner.LockedControls);
      {$ENDIF}
      lstProtected.Items.Assign(FormDesigner.ProtectedControls);
      Result:=ShowModal=mrOk;
      if Result then
        with FormDesigner do
        begin
          TransparentControls.Assign(lstTransparent.Items);
          {$IFDEF TFD1COMPATIBLE}
          FixedControls.Assign(lstLocked.Items);
          {$ELSE}
          LockedControls.Assign(lstLocked.Items);
          {$ENDIF}
          ProtectedControls.Assign(lstProtected.Items);
        end;
    end
    else Result:=False;
  finally
    Free;
  end;
end;

procedure Tfrm_createdesignerEditor.UpdateButtons;
begin
  with ActiveList,Items do
  begin
    btnDelete.Enabled:=ItemIndex<>-1;
    btnClear.Enabled:=Count>0;
  end;
end;

procedure Tfrm_createdesignerEditor.UpdateLists;
begin
  lstLocked.Visible:=rgControls.ItemIndex=0;
  lstProtected.Visible:=rgControls.ItemIndex=1;
  lstTransparent.Visible:=rgControls.ItemIndex=2;
  with ActiveList do
    if (Items.Count>0) and (ItemIndex=-1) then ItemIndex:=0;
  UpdateButtons;
end;

function Tfrm_createdesignerEditor.ActiveList: TMyListBox;
begin
  case rgControls.ItemIndex of
    0: Result:=lstLocked;
    1: Result:=lstProtected;
  else Result:=lstTransparent;
  end;
end;

procedure Tfrm_createdesignerEditor.FillList(AOwner: TComponent; ListType: TListType; Target: TStrings; Exclude: TStrings; AName: string);
var
  i: Integer;
begin
  with AOwner do
    for i:=0 to Pred(ComponentCount) do
      if not (Components[i] is TCustomFormDesigner) then
      begin
        if (not Assigned(Exclude) or (Exclude.IndexOf(Components[i].Name)=-1)) then
          Target.Add(AName+Components[i].Name);
        {$IFNDEF NOFRAMES}
        if Components[i] is TCustomFrame then
          FillList(Components[i],ListType,Target,Exclude,AName+Components[i].Name+'.');
        {$ENDIF}
      end;
end;

constructor Tfrm_createdesignerEditor.Create(AOwner: TComponent);
begin
  inherited Create(Application);
end;

procedure Tfrm_createdesignerEditor.FormCreate(Sender: TObject);
begin
  if GetACP=936 then
  begin
    Self.Caption:='控件选择';
    with rgControls do
    begin
      Caption:='控件类型';
      items.clear;
      items.append('锁');
      items.append('保护');
      items.append('透明');
    end;
  end else If GetACP=950 then
  begin
    Self.Caption:='北ン匡拒';
    with rgControls do
    begin
      Caption:='北ン摸

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -