资源说明:不用第三方控件,让richEdit支持图片与表格换行
DELPHI 6 提供的RICHEDIT是1.0,并不支持图片,对复杂表格也会乱成一团,如何在DELPHI原有控件的基础上做少量修改,使之支持显示图片与正确显示表格,其实只需要几行就好了,方法如下:
找到richEdit控件所在单元ComCtrls.pas (在SOURCE\VCL)
//第一步
procedure TCustomRichEdit.CreateParams(var Params: TCreateParams);
const
// RichEditModuleName = 'RICHED32.DLL';//原来语句
// RichEditClassName = 'RICHEDIT'; //原来语句
RichEditModuleName = 'Msftedit.dll'; //改后语句
RichEditClassName = 'RichEdit50W'; //改后语句
//第二步
procedure TCustomRichEdit.CreateWnd;
....
//加入一行要放在 CreateWnd 因为此时 HANDLE已建立
Perform(EM_SetOleCallback, 0, Longint(TRichEditOleCallback.Create(TRichEdit(self)) as IRichEditOleCallback)) ;
//第三步
procedure TCustomRichEdit.WMRButtonUp(var Message: TWMRButtonUp);
begin
inherited;
// RichEd20 does not pass the WM_RBUTTONUP message to defwndproc,
// so we get no WM_CONTEXTMENU message. Simulate message here.
// if Win32MajorVersion < 5 then //是原有1.0的要去掉
Perform(WM_CONTEXTMENU, Handle, LParam(PointToSmallPoint(
ClientToScreen(SmallPointToPoint(Message.Pos)))));
end;
//第四步
procedure TRichEditStrings.Insert(Index: Integer; const S: string);
....
//要去掉后面两名
// 1.0 uses, 2.0 will error happened 2011
// if RichEdit.SelStart <> (Selection.cpMax + Length(Str)) then //是原有1.0的要去掉
// raise EOutOfResources.Create(sRichEditInsertError); //是原有1.0的要去掉
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。