I was talking about this AppendRichEdit() method.
Happy it works as expected.
Code has already be proven by users, I suspect.
Kind regards
Kurt
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;