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

📄 itempropertyunit.pas

📁 三层的通用架构
💻 PAS
字号:
unit ItemPropertyUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, Buttons, ExtCtrls, ExtDlgs;

type
  TItemPropertyForm = class(TForm)
    PageControl1: TPageControl;
    Button1: TButton;
    Button2: TButton;
    TabSheet1: TTabSheet;
    Edit1: TEdit;
    TabSheet2: TTabSheet;
    Label1: TLabel;
    Label2: TLabel;
    Edit2: TEdit;
    Label3: TLabel;
    Edit3: TEdit;
    Label4: TLabel;
    Edit4: TEdit;
    Label5: TLabel;
    Edit5: TEdit;
    TabSheet3: TTabSheet;
    OpenPictureDialog1: TOpenPictureDialog;
    Panel1: TPanel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Panel2: TPanel;
    Label9: TLabel;
    Edit9: TEdit;
    Button3: TButton;
    Label10: TLabel;
    Edit10: TEdit;
    Button4: TButton;
    Label11: TLabel;
    Edit11: TEdit;
    Button5: TButton;
    Panel3: TPanel;
    Bevel1: TBevel;
    RadioButton2: TRadioButton;
    RadioButton1: TRadioButton;
    Panel4: TPanel;
    Label12: TLabel;
    ComboBox1: TComboBox;
    Panel5: TPanel;
    Label13: TLabel;
    Edit12: TEdit;
    Panel6: TPanel;
    Label14: TLabel;
    Edit13: TEdit;
    Panel7: TPanel;
    Label15: TLabel;
    Edit14: TEdit;
    Button6: TButton;
    Label16: TLabel;
    Edit15: TEdit;
    OpenDialog1: TOpenDialog;
    Button7: TButton;
    Label17: TLabel;
    Edit16: TEdit;
    Label18: TLabel;
    Edit17: TEdit;
    Memo3: TMemo;
    Memo2: TMemo;
    Memo1: TMemo;
    CheckBox1: TCheckBox;
    Panel8: TPanel;
    Label22: TLabel;
    Button8: TButton;
    Label23: TLabel;
    Edit18: TEdit;
    Edit19: TEdit;
    Memo4: TMemo;
    ComboBoxEx1: TComboBoxEx;
    ComboBoxEx2: TComboBoxEx;
    ComboBoxEx3: TComboBoxEx;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Edit4KeyPress(Sender: TObject; var Key: Char);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure Button8Click(Sender: TObject);
  private
    { Private declarations }
    FSaveFlag: Boolean;
    procedure SetRadioButton;
    procedure SetComboBoxEx(ComboBoxEx: TComboBoxEx);
  public
    { Public declarations }
    ItemName, CaptionStr: string;
  end;

var
  ItemPropertyForm: TItemPropertyForm;

implementation

uses MainUnit;

{$R *.dfm}

procedure TItemPropertyForm.Button1Click(Sender: TObject);
begin
  FSaveFlag := True;
  Close;
end;

procedure TItemPropertyForm.Button2Click(Sender: TObject);
begin
  FSaveFlag := False;
  Close;
end;

procedure TItemPropertyForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  TheMainForm.SetItemProperty(ItemName, FSaveFlag);
  Action := caFree;
  ItemPropertyForm := nil;
end;

procedure TItemPropertyForm.FormCreate(Sender: TObject);
begin
  OpenDialog1.InitialDir := ExtractFilePath(Application.ExeName);
  OpenPictureDialog1.InitialDir := ExtractFilePath(Application.ExeName);
  FSaveFlag := False;
  SetComboBoxEx(ComboBoxEx1);
  SetComboBoxEx(ComboBoxEx2);
  SetComboBoxEx(ComboBoxEx3);
  PageControl1.ActivePageIndex := 0;
  Label6.Hint := '     小图标               '+#13#10+
                 ' 指功能组树型图中未选中项 '+#13#10+
                 ' 目使用的图标和功能列表中 '+#13#10+
                 ' 在不是大图标查看方式下使 '+#13#10+
                 ' 用的图标';
  ComboBoxEx1.Hint := Label6.Hint;
  Label9.Hint := Label6.Hint;
  Edit9.Hint := Label9.Hint;
  Label7.Hint := '     选中图标             '+#13#10+
                 ' 指功能组树型图中选中项目 '+#13#10+
                 ' 使用的图标.对于功能项,此 '+#13#10+
                 ' 项无意义,可为空;         ';
  ComboBoxEx2.Hint := Label7.Hint;
  Label10.Hint := Label7.Hint;
  Edit10.Hint := Label10.Hint;
  Label8.Hint := '     大图标               '+#13#10+
                 ' 指功能列表中在大图标查看 '+#13#10+
                 ' 方式下使用的图标';
  ComboBoxEx3.Hint := Label8.Hint;
  Label11.Hint := Label8.Hint;
  Edit11.Hint := Label11.Hint;
  Label12.Hint := ' FORM: Delphi表单, 其类应 '+#13#10+
                  '       在本系统中声明;    '+#13#10+
                  ' DLL:  包含本系统指定格式 '+#13#10+
                  '       输出函数的动态链接 '+#13#10+
                  '       库或Delphi包;      '+#13#10+
                  ' EXE:  一般指可执行文件,  '+#13#10+
                  '       也可以是具有打开方 '+#13#10+
                  '       式的任何文件.      '+#13#10+
                  ' PB:   PowerBuilder动态库 '+#13#10+
                  '       PBD中的窗口类名.   ';
  ComboBox1.Hint := Label12.Hint;
end;

procedure TItemPropertyForm.FormShow(Sender: TObject);
begin
  SetRadioButton;
  ComboBox1Change(nil);
end;

procedure TItemPropertyForm.RadioButton1Click(Sender: TObject);
begin
  SetRadioButton;
end;

procedure TItemPropertyForm.SetRadioButton;
begin
  if RadioButton1.Checked then
  begin
    Panel1.Visible := True;
    Panel2.Visible := False;
  end
  else begin
    Panel2.Visible := True;
    Panel1.Visible := False;
  end;
end;

procedure TItemPropertyForm.SetComboBoxEx(ComboBoxEx: TComboBoxEx);
var
  i: Integer;
  ImageList: TImageList;
begin
  ImageList := TImageList(ComboBoxEx.Images);
  for i := 0 to ImageList.Count - 1 do
    with ComboBoxEx.ItemsEx.Add do
    begin
      ImageIndex := i;
      Caption := IntToStr(i);
      SelectedImageIndex := ImageIndex;
      OverlayImageIndex := -1;
    end;
end;

procedure TItemPropertyForm.Button3Click(Sender: TObject);
begin
  with OpenPictureDialog1 do
  begin
    InitialDir := ExtractFilePath(Edit9.Text);
    FileName := ExtractFileName(Edit9.Text);
    FilterIndex := 6;
    if (FileName = '') or (Pos(UpperCase(ExtractFileExt(FileName)) + '/', '.BMP/.ICO/.WMF/.EMF/') > 0) then
      FilterIndex := 1;
    if Execute then
      Edit9.Text := FileName;
  end;
end;

procedure TItemPropertyForm.Button4Click(Sender: TObject);
begin
  with OpenPictureDialog1 do
  begin
    InitialDir := ExtractFilePath(Edit10.Text);
    FileName := ExtractFileName(Edit10.Text);
    FilterIndex := 6;
    if (FileName = '') or (Pos(UpperCase(ExtractFileExt(FileName)) + '/', '.BMP/.ICO/.WMF/.EMF/') > 0) then
      FilterIndex := 1;
    if Execute then
      Edit10.Text := FileName;
  end;
end;

procedure TItemPropertyForm.Button5Click(Sender: TObject);
begin
  with OpenPictureDialog1 do
  begin
    InitialDir := ExtractFilePath(Edit11.Text);
    FileName := ExtractFileName(Edit11.Text);
    FilterIndex := 6;
    if (FileName = '') or (Pos(UpperCase(ExtractFileExt(FileName)) + '/', '.BMP/.ICO/.WMF/.EMF/') > 0) then
      FilterIndex := 1;
    if Execute then
      Edit11.Text := FileName;
  end;
end;

procedure TItemPropertyForm.Edit4KeyPress(Sender: TObject; var Key: Char);
begin
  if not ((Key >= '0') and (Key <= '9') or (Key = #8)) then
    Key := #7;
end;

procedure TItemPropertyForm.Button6Click(Sender: TObject);
begin
  with OpenDialog1 do
  begin
    Filter := '动态链接库或Delphi包 (*.dll,*.bpl)|*.dll;*.bpl|动态链接库 (*.dll)|*.dll|Delphi包文件 (*.bpl)|*.bpl|所有文件 (*.*)|*.*';
    InitialDir := ExtractFilePath(Edit13.Text);
    FileName := ExtractFileName(Edit13.Text);
    FilterIndex := 4;
    if (FileName = '') or (Pos(UpperCase(ExtractFileExt(FileName)) + '/', '.DLL/.BPL/') > 0) then
      FilterIndex := 1;
    if Execute then
      Edit13.Text := FileName;
  end;
end;

procedure TItemPropertyForm.Button7Click(Sender: TObject);
begin
  with OpenDialog1 do
  begin
    Filter := 'EXE文件 (*.exe)|*.exe|所有文件 (*.*)|*.*';
    InitialDir := ExtractFilePath(Edit14.Text);
    FileName := ExtractFileName(Edit14.Text);
    FilterIndex := 2;
    if (FileName = '') or (Pos(UpperCase(ExtractFileExt(FileName)) + '/', '.EXE/') > 0) then
      FilterIndex := 1;
    if Execute then
    begin
      Edit14.Text := FileName;
      Edit16.Text := ExtractFilePath(FileName);
    end;
  end;
end;

procedure TItemPropertyForm.ComboBox1Change(Sender: TObject);
begin
  case ComboBox1.ItemIndex of
    0: begin
         Panel5.Visible := True;
         Panel6.Visible := False;
         Panel7.Visible := False;
         Panel8.Visible := False;
       end;
    1: begin
         Panel5.Visible := False;
         Panel6.Visible := True;
         Panel7.Visible := False;
         Panel8.Visible := False;
       end;
    2: begin
         Panel5.Visible := False;
         Panel6.Visible := False;
         Panel7.Visible := True;
         Panel8.Visible := False;
       end;
    3: begin
         Panel5.Visible := False;
         Panel6.Visible := False;
         Panel7.Visible := False;
         Panel8.Visible := True;
       end;
  end;
end;

procedure TItemPropertyForm.Button8Click(Sender: TObject);
begin
  with OpenDialog1 do
  begin
    Filter := 'PowerBuilder动态库 (*.pbd)|*.pbd|所有文件 (*.*)|*.*';
    InitialDir := ExtractFilePath(Edit18.Text);
    FileName := ExtractFileName(Edit18.Text);
    FilterIndex := 2;
    if (FileName = '') or (Pos(UpperCase(ExtractFileExt(FileName)) + '/', '.PBD/') > 0) then
      FilterIndex := 1;
    if Execute then
      Edit18.Text := FileName;
  end;
end;

end.

⌨️ 快捷键说明

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