?? unit1.pas
字號:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ActnCtrls, ToolWin, ActnMan, ActnMenus, StdActns, ExtActns,
ActnList, ImgList, StdCtrls, ComCtrls,About;
type
TForm1 = class(TForm)
ActionManager1: TActionManager;
ImageList1: TImageList;
FileNew: TAction;
FileSave: TAction;
HelpIndex: TAction;
HelpAbout: TAction;
EditCut1: TEditCut;
EditCopy1: TEditCopy;
EditPaste1: TEditPaste;
EditSelectAll1: TEditSelectAll;
EditUndo1: TEditUndo;
EditDelete1: TEditDelete;
RichEditBold1: TRichEditBold;
RichEditItalic1: TRichEditItalic;
RichEditUnderline1: TRichEditUnderline;
RichEditStrikeOut1: TRichEditStrikeOut;
RichEditBullets1: TRichEditBullets;
RichEditAlignLeft1: TRichEditAlignLeft;
RichEditAlignRight1: TRichEditAlignRight;
RichEditAlignCenter1: TRichEditAlignCenter;
HelpContents1: THelpContents;
FileOpen1: TFileOpen;
FileSaveAs1: TFileSaveAs;
FileExit1: TFileExit;
SearchFind1: TSearchFind;
SearchFindNext1: TSearchFindNext;
SearchReplace1: TSearchReplace;
SearchFindFirst1: TSearchFindFirst;
ActionMainMenuBar1: TActionMainMenuBar;
ActionToolBar1: TActionToolBar;
StatusBar1: TStatusBar;
ToolBar1: TToolBar;
FontSize: TEdit;
UpDown1: TUpDown;
ToolButton1: TToolButton;
boldbutton: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton3: TToolButton;
ToolButton6: TToolButton;
ToolButton7: TToolButton;
ToolButton8: TToolButton;
ToolButton9: TToolButton;
ToolButton10: TToolButton;
RichEdit1: TRichEdit;
FontName: TComboBoxEx;
procedure FileNewExecute(Sender: TObject);
procedure FileOpen1Accept(Sender: TObject);
procedure FileSaveExecute(Sender: TObject);
procedure HelpContents1Execute(Sender: TObject);
procedure HelpIndexExecute(Sender: TObject);
procedure HelpAboutExecute(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ShowHint(Sender: TObject);
procedure FileSaveAs2Execute(Sender: TObject);
procedure FontNameChange(Sender: TObject);
procedure FontSizeChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
FileName:String;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FileNewExecute(Sender: TObject);
begin
RichEdit1.Clear;
FileName:='未命名文件.txt';
StatusBar1.Panels[0].Text:=FileName;
end;
procedure TForm1.FileOpen1Accept(Sender: TObject);
begin
RichEdit1.Lines.LoadFromFile(FileOpen1.Dialog.FileName);
FileName:=FileOpen1.Dialog.FileName;
Form1.Caption:=FileName;
StatusBar1.Panels[0].Text:=FileName;
end;
procedure TForm1.FileSaveExecute(Sender: TObject);
begin
if FileName='未命名文件.txt'then
FileSaveAs1.Execute
else
RichEdit1.Lines.SaveToFile(FileName);
end;
procedure TForm1.HelpContents1Execute(Sender: TObject);
const
HELP_TAB=15;
CONTENTS_ACTIVE=-3;
begin
Application.HelpCommand(HELP_TAB,CONTENTS_ACTIVE);
end;
procedure TForm1.HelpIndexExecute(Sender: TObject);
Const
HELP_TAB=15;
INDEX_ACTIVE=-2;
begin
Application.HelpCommand(HELP_TAB,INDEX_ACTIVE);
end;
procedure TForm1.HelpAboutExecute(Sender: TObject);
begin
with TAboutBox.Create(Self) do
try
showModal;
finally
Free;
end;
end;
procedure TForm1.ShowHint(Sender: TObject);
begin
if Length(Application.Hint) > 0 then
begin
StatusBar1.SimplePanel := True;
StatusBar1.SimpleText := Application.Hint;
end
else StatusBar1.SimpleText := '歡迎使用本軟件!';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.HelpFile:=ExtractFilePath(Application.ExeName)+'TextEditor.hlp';
end;
procedure TForm1.FileSaveAs2Execute(Sender: TObject);
begin
RichEdit1.Lines.SaveToFile(FileName);
end;
procedure TForm1.FontNameChange(Sender: TObject);
begin
if FontName.Text='ANSI_CHARSET' then
RichEdit1.Font.Charset:=ANSI_CHARSET;
if FontName.Text='ARABIC_CHARSET' then
RichEdit1.Font.Charset:=ARABIC_CHARSET;
if FontName.Text='BALTIC_CHARSET' then
RichEdit1.Font.Charset:=BALTIC_CHARSET;
end;
procedure TForm1.FontSizeChange(Sender: TObject);
begin
RichEdit1.Font.Size:= StrToInt(FontSize.Text);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -