📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, DesignCommon, ComCtrls, TeeProcs, TeEngine,
Chart, ExtCtrls, Mask, Buttons, DB, ADODB, Grids, ValEdit, DBGrids,
OleCtrls, SHDocVw, CheckLst;
type
TForm1 = class(TForm)
designpanel: TPanel;
Label1: TLabel;
SpeedButton2: TSpeedButton;
Edit1: TEdit;
Memo1: TMemo;
Button1: TButton;
CheckBox1: TCheckBox;
RadioButton1: TRadioButton;
Panel1: TPanel;
SpeedButton1: TSpeedButton;
Image1: TImage;
Shape1: TShape;
ListBox1: TListBox;
BitBtn1: TBitBtn;
GroupBox1: TGroupBox;
Button2: TButton;
CheckBox2: TCheckBox;
ComboBox1: TComboBox;
RadioGroup1: TRadioGroup;
MaskEdit1: TMaskEdit;
ColorBox1: TColorBox;
Chart1: TChart;
TrackBar1: TTrackBar;
ProgressBar1: TProgressBar;
UpDown1: TUpDown;
DateTimePicker1: TDateTimePicker;
MonthCalendar1: TMonthCalendar;
TreeView1: TTreeView;
ListView1: TListView;
ValueListEditor1: TValueListEditor;
MainMenu1: TMainMenu;
f1: TMenuItem;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
WsFormDesigner1: TWsFormDesigner;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
CheckListBox1: TCheckListBox;
ListBox2: TListBox;
N6: TMenuItem;
N7: TMenuItem;
procedure N4Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure WsFormDesigner1SelectionChange(sender: TDesignControl;
ChangeType: TChangeType);
procedure WsFormDesigner1BeforeDesign(Sender: TObject);
procedure WsFormDesigner1Dirty(Sender: TObject);
procedure WsFormDesigner1EndDesign(Sender: TObject);
procedure WsFormDesigner1ObjectClicked(sender: TDesignControl);
procedure N6Click(Sender: TObject);
function WsFormDesigner1TransFieldName(FName: String): String;
procedure WsFormDesigner1EditProp(propname: String;
propObject: TObject);
procedure N7Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses AboutFm;
{$R *.dfm}
procedure TForm1.N4Click(Sender: TObject);
begin
TMenuItem(sender).Checked:=not TMenuItem(sender).Checked;
if(TMenuItem(sender).Checked) then
WsFormDesigner1.BeginDesign(designpanel)
else
WsFormDesigner1.EndDesign;
end;
procedure TForm1.N1Click(Sender: TObject);
begin
if(SaveDialog1.Execute) then
WsFormDesigner1.SaveToBinaryFile(SaveDialog1.FileName);
end;
procedure TForm1.N2Click(Sender: TObject);
begin
if(OpenDialog1.Execute) then
TWsFormDesigner.LoadFromBinaryFile(self,OpenDialog1.FileName);
end;
procedure TForm1.N5Click(Sender: TObject);
begin
if(Form2=nil) then
Form2:=TForm2.Create(nil);
form2.ShowModal;
end;
procedure TForm1.WsFormDesigner1SelectionChange(sender: TDesignControl;
ChangeType: TChangeType);
begin
//showmessage(sender.getcontrol.Name);
end;
procedure TForm1.WsFormDesigner1BeforeDesign(Sender: TObject);
begin
//showmessage('WsFormDesigner1BeforeDesign');
end;
procedure TForm1.WsFormDesigner1Dirty(Sender: TObject);
begin
//showmessage('Dirty');
end;
procedure TForm1.WsFormDesigner1EndDesign(Sender: TObject);
begin
//showmessage('EndDesign');
end;
procedure TForm1.WsFormDesigner1ObjectClicked(sender: TDesignControl);
begin
//showmessage(sender.getcontrol.Name);
end;
procedure TForm1.N6Click(Sender: TObject);
var
str:string;
cclass:TClass;
begin
WsFormDesigner1.DesignState:=DesignCommon.dsInsert;
str:=LowerCase(InputBox('请输入类名','请输入类名如(TButton,TPanel)等',''));
if(length(str)=0) then exit;
if(str='tlabel') then
cclass:=TLabel;
if(str='tedit') then
cclass:=TEdit;
if(str='tmemo') then
cclass:=TMemo;
if(str='tbutton') then
cclass:=TButton;
if(str='tcheckbox') then
cclass:=TCheckBox;
if(str='tradiobutton') then
cclass:=TRadioButton;
if(str='tlistbox') then
cclass:=TListBox;
if(str='tcombobox') then
cclass:=TComboBox;
if(str='tgroupbox') then
cclass:=TGroupBox;
if(str='tradiogroup') then
cclass:=TRadioGroup;
if(str='tpanel') then
cclass:=TPanel;
if(str='tbitbtn') then
cclass:=TBitBtn;
if(str='tspeedbutton') then
cclass:=TSpeedButton;
if(str='tmaskedit') then
cclass:=TMaskEdit;
if(str='tstringgrid') then
cclass:=TStringGrid;
if(str='tdrawgrid') then
cclass:=TDrawGrid;
if(str='timage') then
cclass:=TImage;
if(str='tshape') then
cclass:=TShape;
if(str='tscrollbox') then
cclass:=TScrollBox;
if(str='tchecklistbox') then
cclass:=TCheckListBox;
if(str='tstatictext') then
cclass:=TStaticText;
if(str='tvaluelisteditor') then
cclass:=TValueListEditor;
if(str='tcolorbox') then
cclass:=TColorBox;
if(str='trichedit') then
cclass:=TRichEdit;
if(str='twebbrowser') then
cclass:=TWebBrowser;
if(cclass.InheritsFrom(TControl)) then
WsFormDesigner1.InsertControlClass:=TControlClass(cclass);
end;
function TForm1.WsFormDesigner1TransFieldName(FName: String): String;
begin
if(FName='Date') then
result:='时间';
end;
procedure TForm1.WsFormDesigner1EditProp(propname: String;
propObject: TObject);
begin
//
end;
procedure TForm1.N7Click(Sender: TObject);
begin
WsFormDesigner1.DesignState:=DesignCommon.dsSelect;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -