2

使用delphi 7 TRichEdit组件,通过复制和粘贴从msword文档中导入RTF数据,但是如果数据包含在一个框中,则无法正确显示,即

在此处输入图像描述

请协助

4

2 回答 2

3

尝试使用以下内容,它应该将该类子TRichEdit类化为 4.1 版。但是我不知道 Delphi 7 是否支持插入类,所以只需尝试粘贴以下代码并尝试构建项目。
如果它编译,那么如果你放置一个TRichEdit组件并运行项目,你应该得到 RichEdit 4.1。

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, RichEdit;

type
  TRichEdit = class(ComCtrls.TRichEdit)
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  end;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  FRichEditModule: THandle;

implementation

{$R *.dfm}

{ TRichEdit }

procedure TRichEdit.CreateParams(var Params: TCreateParams);
const
  RichEditClassName = 'RICHEDIT50A';
  RichEditModuleName = 'MSFTEDIT.DLL';
  HideScrollBarsStyle: array[Boolean] of DWORD = (ES_DISABLENOSCROLL, 0);
  HideSelectionsStyle: array[Boolean] of DWORD = (ES_NOHIDESEL, 0);
begin
  if FRichEditModule = 0 then
  begin
    FRichEditModule := LoadLibrary(RichEditModuleName);
    if FRichEditModule <= HINSTANCE_ERROR then
      FRichEditModule := 0;
  end;
  inherited CreateParams(Params);    
  CreateSubClass(Params, RichEditClassName);
  Params.Style := Params.Style or HideScrollBarsStyle[HideScrollBars] or
    HideSelectionsStyle[HideSelection];
  Params.WindowClass.style := Params.WindowClass.style and
    not (CS_HREDRAW or CS_VREDRAW);
end;

initialization

finalization
  if FRichEditModule <> 0 then
    FreeLibrary(FRichEditModule);

end.
于 2012-05-08T13:44:14.437 回答
2

终于开工了

就像将 Riched20.dll(最新版​​本)添加到应用程序文件夹一样简单

于 2012-05-10T11:39:11.280 回答