博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
修改greatis form designer使其添加对三方控件的支持
阅读量:5994 次
发布时间:2019-06-20

本文共 8285 字,大约阅读时间需要 27 分钟。

试用版本没有源码,每次运行之前会提示“要注册”的信息,没有使用的时间限制,可以用。

缺点:拖放上去的控件不能设置其属性,只好在脚本里面设置。

unit ToolForm;

{$DEFINE EHLIB}          // 增加支持EHLIB ADD BY CXG
{$DEFINE RAIZE} // 增加支持RAIZE ADD BY CXG
{$DEFINE DBANYWHERE}  // 增加支持DBANYWHERE ADD BY CXG
interface

uses

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls, Buttons, ExtCtrls, Clipbrd, Menus, FDMain, FDCmpPal,
  Mask
  {$IFDEF EHLIB}
  ,DBGridEh, GridsEh, PrnDbgeh, DBCtrlsEh
  {$ENDIF}
  ,ActnList
  ,Grids, CheckLst, AppEvnts, Chart
  ,DB, DBClient
  ,XPMan
  ,DBGrids, DBCtrls, DbChart
  ,ADODB
  {$IFDEF RAIZE}
  ,rzpanel, rztabs, rzsplit, rzedit, rzbtnedt, rzdbedit, rzdbbned, rzgrids
  ,rzbutton, rztray, rzbhints, rzcmbobx, rzdbcmbo, rzlstbox, rzdblist
  {$ENDIF}
  {$IFDEF DBANYWHERE}
  ,remoteStoredProc, remoteUpdateSql, RemoteUdpDataSet, remoteUdpConnection
  ,applicationUpdate, remoteTcpConnection
  {$ENDIF}
  ;

type

  TfrmToolForm = class(TForm)
    pgcMain: TPageControl;
    opdMain: TOpenDialog;
    svdMain: TSaveDialog;
    pmnMain: TPopupMenu;
    mniLock: TMenuItem;
    mniAlignToGrid: TMenuItem;
    mniCut: TMenuItem;
    mniCopy: TMenuItem;
    mniPaste: TMenuItem;
    mniDelete: TMenuItem;
    mniSep1: TMenuItem;
    mniBringToFront: TMenuItem;
    mniSendToBack: TMenuItem;
    mniSep2: TMenuItem;
    mniSelectAll: TMenuItem;
    Panel1: TPanel;
    sbtOpen: TSpeedButton;
    sbtSave: TSpeedButton;
    sbtAlignToGrid: TSpeedButton;
    sbtLock: TSpeedButton;
    sbtCut: TSpeedButton;
    sbtCopy: TSpeedButton;
    sbtPaste: TSpeedButton;
    sbtDelete: TSpeedButton;
    sbtSetup: TSpeedButton;
    sbtAbout: TSpeedButton;
    sbtAlign: TSpeedButton;
    sbtSize: TSpeedButton;
    sbtAlignPalette: TSpeedButton;
    sbtTabOrder: TSpeedButton;
    sbtSelectAll: TSpeedButton;
    sbtRelated: TSpeedButton;
    procedure sbtPaletteButtonClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure eveLock(Sender: TObject);
    procedure eveAlign(Sender: TObject);
    procedure eveDelete(Sender: TObject);
    procedure eveCut(Sender: TObject);
    procedure evePaste(Sender: TObject);
    procedure eveCopy(Sender: TObject);
    procedure sbtOpenClick(Sender: TObject);
    procedure sbtSaveClick(Sender: TObject);
    procedure pmnMainPopup(Sender: TObject);
    procedure sbtSetupClick(Sender: TObject);
    procedure sbtAboutClick(Sender: TObject);
    procedure mniBringToFrontClick(Sender: TObject);
    procedure mniSendToBackClick(Sender: TObject);
    procedure sbtAlignClick(Sender: TObject);
    procedure sbtSizeClick(Sender: TObject);
    procedure eveSelectAll(Sender: TObject);
    procedure eveAlignPalette(Sender: TObject);
    procedure eveTabOrder(Sender: TObject);
    procedure sbtRelatedClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    ComponentClass: TComponentClass;
  end;

var

  frmToolForm: TfrmToolForm;

implementation

uses Design, Setup, About, Related;

{$R *.DFM}

{$R DB.RES}
{$IFDEF EHLIB}
  {$R EhLibReg.dcr}
{$ENDIF}
{$IFDEF RAIZE}
  {$R RaizeComponentsVcl_16x16.dcr}
  {$R RaizeComponentsVcl_24x24.dcr}
  {$R RaizeComponentsVcl_32x32.dcr}
{$ENDIF}
{$IFDEF DBANYWHERE}
  {$R remotedataset.dcr}
{$ENDIF}

procedure TfrmToolForm.sbtPaletteButtonClick(Sender: TObject);

begin
  ComponentClass:=(Sender as TPaletteButton).ComponentClass;
  if Assigned(ComponentClass) then frmDesign.cmpFormDesigner.PlaceComponentClass(ComponentClass)
  else frmDesign.cmpFormDesigner.CancelPlacing;
end;

procedure TfrmToolForm.FormShow(Sender: TObject);

begin
  frmDesign.Show;
  CreatePalettePage(pgcMain,'Standard',[TLabel,TEdit,TMemo,TButton,TCheckBox,
    TRadioButton,TListBox,TComboBox,TGroupBox,TRadioGroup,TPanel,
    TMainMenu, TPopupMenu, TActionList],sbtPaletteButtonClick);
  CreatePalettePage(pgcMain,'Additional',[TBitBtn,TSpeedButton,TMaskEdit,TImage,
    TShape,TBevel,TStaticText, TScrollBox, TCheckListBox, TSplitter, TApplicationEvents,
    TStringGrid, TLabeledEdit, TChart],sbtPaletteButtonClick);
  CreatePalettePage(pgcMain,'Win32',[TPageControl, TImageList, TRichEdit,
    TProgressBar, TAnimate, TDateTimePicker, TTreeView, TStatusBar, TToolBar,
    TCoolBar, TXPManifest],sbtPaletteButtonClick);
  CreatePalettePage(pgcMain,'System',[TTimer, TPaintBox],sbtPaletteButtonClick);
  CreatePalettePage(pgcMain,'Dialogs',[TOpenDialog,TSaveDialog,TFontDialog,TColorDialog],sbtPaletteButtonClick);
  {$IFDEF EHLIB}
  CreatePalettePage(pgcMain,'Ehlib',[TDBGridEh, TPrintDBGridEh],sbtPaletteButtonClick);
  {$ENDIF}
  CreatePalettePage(pgcMain,'Data Access',[TDataSource, TClientDataSet],sbtPaletteButtonClick);
  CreatePalettePage(pgcMain,'Data Controls',[TDBGrid, TDBNavigator, TDBEdit,
    TDBMemo, TDBImage, TDBListBox, TDBComboBox, TDBCheckBox, TDBRadioGroup,
    TDBRichEdit, TDBChart],sbtPaletteButtonClick);
  CreatePalettePage(pgcMain,'ADO',[TADOConnection, TADOCommand, TADOStoredProc,
    TADOTable, TADODataSet, TADOQuery],sbtPaletteButtonClick);
  {$IFDEF RAIZE}
  CreatePalettePage(pgcMain,'Raize',[TRzPanel, TRzPageControl, TRzSizePanel,
    TRzToolBar, TRzStatusBar, TRzGroupBox, TRzEdit, TRzButtonEdit, TRzDateTimeEdit,
    TRzMemo, TRzDbEdit, TRzDbButtonEdit, TRzDbDateTimeEdit, TRzDbMemo,
    TRzListBox, TRzCombobox, TRzDbListBox, TRzDbCombobox, TRzButton,
    TRzBitBtn, TRzMenuButton, TRzTrayIcon, TRzBalloonHints] ,sbtPaletteButtonClick);
  {$ENDIF}
  {$IFDEF DBANYWHERE}
  CreatePalettePage(pgcMain,'DBAnyWhere',[TRemoteUdpConnection,
    TRemoteUdpDataSet, TApplicationUpdate, TRemoteStoredProc,
    TRemoteTCPConnection, TRemoteDataSet, TRemoteUpdateSql],sbtPaletteButtonClick);
  {$ENDIF}
end;

procedure TfrmToolForm.eveLock(Sender: TObject);

var
  i,IDX: Integer;
begin
  if Sender<>sbtLock then sbtLock.Down:=not sbtLock.Down;
  {$IFDEF TFD1COMPATIBLE}
  with frmDesign.cmpFormDesigner,FixedControls do
  {$ELSE}
  with frmDesign.cmpFormDesigner,LockedControls do
  {$ENDIF}
    for i:=0 to Pred(ControlCount) do
    begin
      IDX:=IndexOf(Controls[i].Name);
      if sbtLock.Down then
      begin
        if IDX=-1 then Add(Controls[i].Name);
      end
      else
        if IDX<>-1 then Delete(IDX);
    end;
end;

procedure TfrmToolForm.pmnMainPopup(Sender: TObject);

begin
  mniLock.Checked:=sbtLock.Down;
end;

procedure TfrmToolForm.eveAlign(Sender: TObject);

var
  i: Integer;
begin
  with frmDesign.cmpFormDesigner do
    for i:=0 to Pred(ControlCount) do
      if not IsLocked(Controls[i]) then
        AlignToGrid(Controls[i]);
end;

procedure TfrmToolForm.eveDelete(Sender: TObject);

var
  C: TControl;
begin
  if sbtDelete.Enabled then
    with frmDesign.cmpFormDesigner do
    begin
      while ControlCount>0 do
      begin
        C:=Controls[0];
        if C is TComponentContainer then
          TComponentContainer(C).Component.Free
        else C.Free;
      end;
    end;
end;

procedure TfrmToolForm.eveCut(Sender: TObject);

begin
  if sbtCut.Enabled then
    frmDesign.cmpFormDesigner.CutToClipboard;
end;

procedure TfrmToolForm.evePaste(Sender: TObject);

begin
  if sbtPaste.Enabled then
    frmDesign.cmpFormDesigner.PasteFromClipboard;
end;

procedure TfrmToolForm.eveCopy(Sender: TObject);

begin
  if sbtCopy.Enabled then
    frmDesign.cmpFormDesigner.CopyToClipboard;
end;

procedure TfrmToolForm.sbtOpenClick(Sender: TObject);

begin
  with opdMain do
    if Execute then
      frmDesign.cmpFormDesigner.LoadFromDFM(FileName,TDFMFormat(Pred(FilterIndex)));
end;

procedure TfrmToolForm.sbtSaveClick(Sender: TObject);

begin
  with svdMain do
    if Execute then
      frmDesign.cmpFormDesigner.SaveToDFM(FileName,TDFMFormat(Pred(FilterIndex)));
end;

procedure TfrmToolForm.sbtSetupClick(Sender: TObject);

begin
  frmSetup.ShowModal;
end;

procedure TfrmToolForm.sbtAboutClick(Sender: TObject);

begin
  frmAbout.ShowModal;
end;

procedure TfrmToolForm.mniBringToFrontClick(Sender: TObject);

var
  i: Integer;
begin
  with frmDesign.cmpFormDesigner do
  begin
    for i:=Pred(ControlCount) downto 0 do Controls[i].BringToFront;
    Update;
  end;
end;

procedure TfrmToolForm.mniSendToBackClick(Sender: TObject);

var
  i: Integer;
begin
  with frmDesign.cmpFormDesigner do
  begin
    for i:=Pred(ControlCount) downto 0 do Controls[i].SendToBack;
    Update;
  end;
end;

procedure TfrmToolForm.sbtAlignClick(Sender: TObject);

begin
  frmDesign.cmpFormDesigner.AlignDialog;
end;

procedure TfrmToolForm.sbtSizeClick(Sender: TObject);

begin
  frmDesign.cmpFormDesigner.SizeDialog;
end;

procedure TfrmToolForm.eveSelectAll(Sender: TObject);

begin
  frmDesign.cmpFormDesigner.Lock;
  frmDesign.cmpFormDesigner.SelectAll;
  frmDesign.cmpFormDesigner.Unlock;
end;

procedure TfrmToolForm.eveAlignPalette(Sender: TObject);

begin
  frmDesign.cmpFormDesigner.ShowAlignmentPalette;
end;

procedure TfrmToolForm.eveTabOrder(Sender: TObject);

begin
  frmDesign.cmpFormDesigner.TabOrderDialog;
end;

procedure TfrmToolForm.sbtRelatedClick(Sender: TObject);

begin
  frmRelated.ShowModal;
end;

end.

转载地址:http://onqlx.baihongyu.com/

你可能感兴趣的文章
mysql的二级索引
查看>>
Cobar是提供关系型数据库(MySQL)分布式服务的中间件
查看>>
Oracle当前用户SQL
查看>>
JavaScript学习笔记之下拉选择框的操作
查看>>
ProgressDialog使用总结
查看>>
安装完操作系统后,必备开发软件安装
查看>>
网络爬虫基本原理(一)
查看>>
让Win8自动登录免输入密码的小技巧
查看>>
RSA3:预提取数据
查看>>
MinGW 介绍
查看>>
注册域名到搜索引擎
查看>>
Eclipse中如何安装和使用GrepCode插件 (转)
查看>>
神经网络和机器学习、强人工智能
查看>>
JavaScript内部原理实践——真的懂JavaScript吗?(转)
查看>>
【DeepLearning】Exercise:Softmax Regression
查看>>
Android JNI入门第四篇——Android.mk文件分析
查看>>
Get a developer license for windows store app
查看>>
策略模式
查看>>
Android Studio导入第三方类库的方法
查看>>
zxing二维码
查看>>