View Issue Details

IDProjectCategoryView StatusLast Update
0004782JEDI VCL00 JVCL Componentspublic2009-09-23 17:09
ReportertetarddAssigned Toobones 
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.39 
Summary0004782: jvRichEdit - Create GetTextlenEx function
DescriptionThe current method to get the length of the content for printing (EM_FormatRange) is:

3891 if RichEditVersion >= 2 then
 3892 begin
 3893 with TextLenEx do
 3894 begin
 3895 Flags := GTL_DEFAULT;
 3896 codepage := CP_ACP;
 3897 end;
 3898 MaxLen := Perform(EM_GETTEXTLENGTHEX, WParam(@TextLenEx), 0);
 3899 end
 3900 else
 3901 MaxLen := GetTextLen;

This seems to imply that calling GetTextlen is not valid for versions 2 and above. Therefore, it means that for version 2 and above, one cannot print reliably the RTF content using the EM_FORMATRANGE in our own canvas (for example, if I have a print preview control) as we'd have to dig in the code of TJvRichEdit to discover that GetTextLen (public) is rubbish.

I suggest the following:
Create a ***public*** GetTextLenEx function that is like this:

Function GetTextLenEx : Integer;
   TextLenEx: TGetTextLengthEx;
     if RichEditVersion >= 2 then
       with TextLenEx do
         Flags := GTL_DEFAULT;
         codepage := CP_ACP;
       Result := Perform(EM_GETTEXTLENGTHEX, WParam(@TextLenEx), 0);
        Result := GetTextLen;

and in method print, do only:

MaxLen := GetTextlenEx; to replace lines 3891 to 3901.

and maybe mark GetTextLen as deprecated.
TagsNo tags attached.



2009-07-09 10:21

administrator   ~0015797

Could you please provide the zipped sources of a sample application showing this?


2009-08-04 09:37

administrator   ~0015903

Hello, any news?


2009-08-09 11:54

reporter   ~0015969

No need for an example to show this. I have an app with several controls holding user data, e.g. a series of TEdit, TStringGrid, etc., one of them being a TJvRichEdit.

To print my data in one overal document, I have to use the printer canvas and print the text in the TEdits, the lines in the TStringGrid, etc, in the order they are on the screen, one data after the other.
When I therefore have to print the content of the TJvRichEdit on the canvas, I have to use EM_FORMATRANGE to print on that canvas. For this of course, I hit the problem described above.

Remember: A TJvRichEdit does not always have to be a single standalone control whose content is always printed using TJvRichEdit.Print but can be part of a more complex UI with a complex set of controls and therefore may have to be printed using more low-level calls to EM_FORMATRANGE.


2009-08-09 18:50

administrator   ~0015970

Without an example, I cannot test. If I cannot test, I cannot try to solve...


2009-08-09 20:55

reporter   ~0015971

Sorry, it seems I'm failing to communicate something quite obvious it seems.

Have a look at this:, this is exactly what I'm requesting, but make the GetPreciseTextLen a public function of TjvRichEdit.

Also, try to think about the need people have to provide print previews in their app. How do you do that properly with TjvRichEdit, given the embarcadero doc.?


2009-09-23 17:09

administrator   ~0016165

Thanks for the details, this is now in SVN.

Issue History

Date Modified Username Field Change
2009-05-21 09:58 tetardd New Issue
2009-07-06 14:11 obones Status new => acknowledged
2009-07-09 10:21 obones Note Added: 0015797
2009-07-09 10:21 obones Status acknowledged => feedback
2009-08-04 09:37 obones Note Added: 0015903
2009-08-09 11:54 tetardd Note Added: 0015969
2009-08-09 18:50 obones Note Added: 0015970
2009-08-09 20:55 tetardd Note Added: 0015971
2009-09-23 17:09 obones Note Added: 0016165
2009-09-23 17:09 obones Status feedback => resolved
2009-09-23 17:09 obones Fixed in Version => Daily / SVN
2009-09-23 17:09 obones Resolution open => fixed
2009-09-23 17:09 obones Assigned To => obones