You are not logged in.
Hello
I´ve to work with TJVRichedit instead of TRichedit because I need RTF-Files with images. Unfortunately the Class/Procedure TGdiPages.appendRichedit doesn´t work in combination with TJVRichedit. There is a endless loop in the repeat.. until Loop. I´ve taken a look at jvcl and in unit JvPrvwRender (Version jvcl348) there is almost the same code(jvprvwRender.pas / TJvPreviewRenderJvRichEdit.DoAddPage) with some little differences. Among others they are sending EM_GETTEXTLENGTHEX and there is another breakoption in then repeat-loop.
I´m not firm with GDI so I tried and it works. Perhaps any body else has the pleasure to work with jvrtf, this solution works for me.
Hope it'll be useful!
Kurt
(* new Method for handling TJVRichEdit *)
procedure TGDIPages.AppendJVRichEdit(RichEditHandle: HWnd);
var
Range: TFormatRange;
LogX, LogY, LastChar, MaxLen, OldMap: integer;
(* Kurt inserted for EM_GETTEXTLENGTHEX *)
TextLenEx: TGetTextLengthEx;
lastLastChar :integer ;
begin
lastLastChar :=0;
with Range do begin
LogX := GetDeviceCaps(fCanvas.Handle, LOGPIXELSX);
LogY := GetDeviceCaps(fCanvas.Handle, LOGPIXELSY);
rcPage.Left := (fPageMarginsPx.Left*1440) div LogX;
rcPage.Right := ((fPhysicalSizePx.x-fPageMarginsPx.Right)*1440) div LogX;
rcPage.Top := ((fPageMarginsPx.Top+fHeaderHeight)*1440) div LogY;
rcPage.Bottom := ((fPhysicalSizePx.y-fPageMarginsPx.Bottom-fFooterHeight)*1440) div LogY;
rc := rcPage;
rc.Top := (fCurrentYPos*1440) div LogY;
LastChar := 0;
//MaxLen := SendMessage(RichEditHandle,WM_GETTEXTLENGTH,0,0);
(*
Kurt
use of message EM_GETTEXTLENGTHEX instead of EM_GETTEXTLENGTH
Now it works with TJvRichEdit
see also Jvcl unit JvPrvwRender.pas Class TJvPreviewRenderJvRichEdit procedure DoAddPage
They' ve had the same problem in 2004 Version???
[url]http://www.codenewsfast.com/cnf/thread/1927716803/permalink.thr-ng976q13492[/url]
*)
MaxLen := sendmessage(RicheditHandle ,EM_GETTEXTLENGTHEX, WParam(@TextLenEx), 0);
chrg.cpMax := -1;
OldMap := SetMapMode(hdc, MM_TEXT);
try
SendMessage(RichEditHandle, EM_FORMATRANGE, 0, 0);
repeat
chrg.cpMin := LastChar;
hdc := fCanvas.Handle;
hdcTarget := hdc;
(* Kurt save of the last value *)
lastLastChar := lastChar;
LastChar := SendMessage(RichEditHandle, EM_FORMATRANGE, 1, Integer(@Range));
if cardinal(LastChar)<cardinal(MaxLen) then begin
NewPageInternal;
DoHeader;
end else
fCurrentYPos := (rc.Bottom*LogY) div 1440;
rc := rcPage;
until (LastChar>=MaxLen) or (LastChar=-1) or (LastChar <= lastLastChar); // Kurt - I´m not really happy , but it works
finally
SendMessage(RichEditHandle, EM_FORMATRANGE, 0, 0);
SetMapMode(hdc, OldMap);
end;
end;
end;
Last edited by Kurt (2014-11-19 12:51:04)
Offline
Hello
I've not tried yet, but in jvcl they have coded both - one for TRichedit and one for TJVRichedit -
I think they have had some reasons for it , but I will try and inform you the next days.
Best regards
Kurt
Offline
Hello,
I´ve analyzed again and found your unit mORMotReport.pas.
The routine appendRichedit in this unit is working for both -TRichedit and TJVRichedit (and you are sending EM_GETTEXTLENGTHEX).
Kind regards
Kurt
Offline