[PrintPreview] GetRichTextRect with an empty RichEdit

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

[PrintPreview] GetRichTextRect with an empty RichEdit

Postby AndrewDiel » September 3rd, 2013, 12:12 pm

I am using GetRichTextRect before PaintRichText to print the contents of a TCustomRichEdit control. I pass it a TDBRichEdit, and it works fine, except when the TDBRichEdit contains no text.

GetRichTextRect, as I understand it, will accept your desired TRect printing area, and then return the bottom position that would be reached when printing the given RTF. If the RTF results in no printing (either because the control is empty or, I have discovered, contains "empty RTF lines" - see below) the returned TRect printing area is not changed. I would expect it to return .Bottom equal to .Top, implying a zero-height TRect.

Might I be missing something?

Example of a blank RTF that I have encountered :

{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil MS Sans Serif;}}
{\colortbl ;\red0\green0\blue0;}
\par }

Part of my code :

Code: Select all
    rParagraph.Left := iPrnAreaLeft + ppOutput^.ConvertX(tpParagraph.iLeftMM100,mmHiMetric,ppOutput^.Units);
    rParagraph.Top := iCurrentYPos;
    rParagraph.Right := iPrnAreaRight - ppOutput^.ConvertX(tpParagraph.iRightMM100,mmHiMetric,ppOutput^.Units);
    rParagraph.Bottom := iPrnAreaBottom;
    iNewCurrentYPos := ppOutput^.GetRichTextRect(rParagraph,creHolder,@iRenderOffset);
    bEndOnThisPage := (iRenderOffset = -1);
    // Do the actual drawing of the paragraph on the current page
    iRenderOffset := iRenderOffsetTemp;
Posts: 2
Joined: September 3rd, 2013, 10:24 am

Re: [PrintPreview] GetRichTextRect with an empty RichEdit

Postby Kambiz » September 7th, 2013, 4:36 pm


I investigated the issue and find out that it is the RichEdit control that ignores the empty content.
It seems you have to write a workaround for the case that the RichEdit is empty.
User avatar
Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 2 guests