## Problem with justify in TPrintPreview

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

### Problem with justify in TPrintPreview

If i open a RTF file with JUSTIFY paragraphe the preview don't justify can u help me?
Seb@stieN
Active Member

Posts: 10
Joined: May 28th, 2003, 7:41 pm

I checked it out with v4.30 of TPrintPreview, and there was no pronlem.

Kambiz

Posts: 2429
Joined: March 7th, 2003, 7:10 pm

I you're General Demo with sample file it's Ok
but
IN RichText Demo it's not OK the text it's not JUSTIFY with you're sample file. WHY and EXISTING A SOLUTION ? ? ?
Seb@stieN
Active Member

Posts: 10
Joined: May 28th, 2003, 7:41 pm

To fix this problem i found a solution but it not very good but it work in version >2
IN
Code: Select all
PaintRichText

Code: Select all
const  EM_SETTYPOGRAPHYOPTIONS = WM_USER + 202;  TO_ADVANCEDTYPOGRAPHY   = 1;

AND
Code: Select all
SendMessage(RichEdit.Handle, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY);

BEFORE
Code: Select all
Range.chrg.cpMin := SendMessage(RichEdit.Handle, EM_FORMATRANGE, 1, integer(@Range));

---
You can Change
TCustomRichEdit
BY
TCustomMemo
With this change you can use JvRichEdit and LMDRichEdit
Seb@stieN
Active Member

Posts: 10
Joined: May 28th, 2003, 7:41 pm

Thanks Sebastian for the fix.

At least on Windows XP there's no problem with rendering justified rich text with the TPrintPreview component. The component doen't render the text itself, and it's the Windows's task to do it. Maybe there's a bug on some versions of common controls, however I don't know about it and it's not my fault, please don't blame me.

In addition, I won't change the parameter's type from TCustomRichEdit to TCustomMemo. A memo control doesn't support EM_FORMATRANGE message. If a rich edit control wrongly drived from a TCustomEdit instead of a TCustomRichEdit, I might not do the same mistake, shall I? If you are sure that the control is a rich edit, type cast it as what it should be, and pass it to the method.

Kambiz

Posts: 2429
Joined: March 7th, 2003, 7:10 pm

I don't blame you.
In internet i found Doc in Richedit controle and there are many version.

You can found some Doc :
http://home.att.net/~robertdunn/Yacs.html (for BCB)

You're preview it's very good
Seb@stieN
Active Member

Posts: 10
Joined: May 28th, 2003, 7:41 pm