📄 simpleu.pas
字号:
unit SimpleU;
{ This demo shows how to use the TWPCustomRtfEdit
which does not link in all the additional stuff as TWPRichText does. }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, WPRTEDefs, WPRTEPaint, WPCTRMemo, ImgList, StdCtrls,
WPUtil, WPIo, ComCtrls, ToolWin;
type
TForm1 = class(TForm)
Panel1: TPanel;
ChangeWordWrap: TCheckBox;
WPValueEdit1: TWPValueEdit;
Button1: TButton;
ToolBar3: TToolBar;
ToolButton6: TToolButton;
ToolButton8: TToolButton;
ToolButton12: TToolButton;
ImageList1: TImageList;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
procedure ChangeWordWrapClick(Sender: TObject);
procedure WPValueEdit1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure ToolButton8Click(Sender: TObject);
procedure ToolButton12Click(Sender: TObject);
private
{ Private-Deklarationen }
public
WPRichText1 : TWPCustomRtfEdit;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ChangeWordWrapClick(Sender: TObject);
begin
WPRichText1.WordWrap := ChangeWordWrap.Checked;
end;
procedure TForm1.WPValueEdit1Change(Sender: TObject);
begin
WPRichText1.Zooming := WPValueEdit1.Value;
end;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
// We are using the low level memo control, not the TWPRichText
WPRichText1 := TWPCustomRtfEdit.Create(Self);
WPRichText1.Parent := Self;
WPRichText1.Align := alClient;
WPRichText1.WordWrap := TRUE;
WPRichText1.LayoutMode := wplayNormal;
// We are using the low level procedures
WPRichText1.Memo.Cursor.WritingTextAttr.SetFontSize(20);
WPRichText1.InputString('WPTools Version 5' + #13);
WPRichText1.Memo.Cursor.WritingTextAttr.SetFontSize(11);
for i := 0 to 100 do
WPRichText1.InputString('aaaa bbbb cccc ');
WPRichText1.Memo.Cursor.WritingTextAttr.IncludeStyle(afsBold);
WPRichText1.InputString(#13 + 'more text' + #13);
WPRichText1.Memo.Cursor.WritingTextAttr.ExcludeStyle(afsBold);
for i := 0 to 100 do
WPRichText1.InputString('aaaa bbbb cccc ');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MessageDlg('procedure TForm1.FormCreate(Sender: TObject);' + #13 + #10 + 'var i: Integer;' + #13 + #10 + 'begin' + #13
+ #10 + ' WPRichText1.Memo.Cursor.WritingTextAttr.SetFontSize(20);' + #13 + #10 +
' WPRichText1.InputString(''WPTools Version 5'' + #13);' + #13 + #10 +
' WPRichText1.Memo.Cursor.WritingTextAttr.SetFontSize(11);' + #13 + #10 + ' for i := 0 to 100 do' + #13 + #10 +
' WPRichText1.InputString(''aaaa bbbb cccc '');' + #13 + #10 +
' WPRichText1.Memo.Cursor.WritingTextAttr.IncludeStyle(afsBold);' + #13 + #10 +
' WPRichText1.InputString(#13 + ''more text'' + #13);' + #13 + #10 +
' WPRichText1.Memo.Cursor.WritingTextAttr.ExcludeStyle(afsBold);' + #13 + #10 +
' for i := 0 to 100 do' + #13 + #10 + ' WPRichText1.InputString(''aaaa bbbb cccc '');' + #13 + #10 + 'end;',
mtWarning, [mbOK], 0);
end;
procedure TForm1.ToolButton6Click(Sender: TObject);
begin
WPRichText1.Clear;
WPRichText1.InputString('');
end;
procedure TForm1.ToolButton8Click(Sender: TObject);
begin
if OpenDialog1.Execute then
WPRichText1.LoadFromFile(OpenDialog1.FileName,true);
end;
procedure TForm1.ToolButton12Click(Sender: TObject);
begin
SaveDialog1.FileName := OpenDialog1.FileName;
if SaveDialog1.Execute then
WPRichText1.SaveToFile(SaveDialog1.FileName);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -