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

📄 editboxu.pas

📁 wptools5 pro 完整源代码 Msword界面的文本编辑器源代码
💻 PAS
字号:
unit EditBoxU;

interface

uses
  Windows, Messages, SysUtils, Controls, Variants, Classes, Graphics, Forms,
  Dialogs, WPRTEPaint, WPRTEDefs, WPCTRMemo, WPCTRRich, stdctrls;

type
  TForm1 = class(TForm)
    WPRichText1: TWPRichText;
    WPRichText2: TWPRichText;
    procedure WPRichText1EditBoxChangeHeight(Sender: TObject; var NewWidth,
      NewHeight: Integer; var Change: Boolean);
    procedure WPRichText2EditBoxChangeHeight(Sender: TObject; var NewWidth,
      NewHeight: Integer; var Change: Boolean);
    procedure WPRichText2EditBoxChangeWidth(Sender: TObject; var NewWidth,
      NewHeight: Integer; var Change: Boolean);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
    // Inital Props:
    WPRichText1.XOffset    := 20; // in twips
    WPRichText2.XOffset    := 20;
    WPRichText1.LayoutMode := wplayNormal;
    WPRichText2.LayoutMode := wplayNormal;
    WPRichText1.ScrollBars := ssHorizontal;
    WPRichText2.ScrollBars := ssNone;
    WPRichText1.EditBoxModes := [wpemAutoSizeHeight];
    WPRichText2.EditBoxModes := [wpemLimitTextWidth,wpemAutoSizeWidth,wpemAutoSizeHeight];
    WPRichText1.EditOptions :=
       WPRichText1.EditOptions + [wpNoVertScrolling];
    WPRichText2.EditOptions :=
       WPRichText1.EditOptions + [wpNoHorzScrolling,wpNoVertScrolling];
    // Also see the events which limit the maximum width and height
end;

// Limit Height of Editor 1
procedure TForm1.WPRichText1EditBoxChangeHeight(Sender: TObject;
  var NewWidth, NewHeight: Integer; var Change: Boolean);
begin
  if WPRichText1.Top + NewHeight>ClientHeight-20 then
  begin
      NewHeight := ClientHeight-20-WPRichText1.Top;
      WPRichText1.ScrollBars := ssBoth;
      WPRichText1.EditOptions :=
         WPRichText1.EditOptions - [wpNoVertScrolling];
   end else
   begin
      WPRichText1.ScrollBars := ssHorizontal;
      WPRichText1.EditOptions :=
         WPRichText1.EditOptions + [wpNoVertScrolling];
   end;
end;

// Limit Height of Editor 2
procedure TForm1.WPRichText2EditBoxChangeHeight(Sender: TObject;
  var NewWidth, NewHeight: Integer; var Change: Boolean);
begin
   if WPRichText2.Top + NewHeight>ClientHeight-20 then
      NewHeight := ClientHeight-20-WPRichText2.Top;
end;

// Limit Width of Editor 2 - word wrap is applied if required
procedure TForm1.WPRichText2EditBoxChangeWidth(Sender: TObject;
  var NewWidth, NewHeight: Integer; var Change: Boolean);
begin
   if WPRichText2.Top + NewHeight>ClientHeight-20 then
   begin
      NewHeight := ClientHeight-20-WPRichText2.Top;
      WPRichText2.ScrollBars := ssVertical;
      WPRichText2.EditOptions :=
         WPRichText2.EditOptions - [wpNoVertScrolling];
   end else
   begin
      WPRichText2.ScrollBars := ssNone;
      WPRichText2.EditOptions :=
         WPRichText2.EditOptions + [wpNoVertScrolling];
   end;
  if WPRichText2.Left + NewWidth>ClientWidth-20 then
      NewWidth := ClientWidth-20-WPRichText2.Left;
end;



end.

⌨️ 快捷键说明

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