Home General

ppRichEdit component very frustrating

edited August 2001 in General
I am finding the ppRichEdit component very testy and frustrating
I'm trying simply to set attributes to the component. Font, Style,Size and
Tabs.

The following is a sample listing:

State
County County County County
County County County County

State
County County County County
County County County County.......

I want the Font :=10, Name := "Arial" and 3 Tabs, and the style of only the
States to be fsBold

Here is the code:
With ppRichText1 do
begin

{ Set the Name of the state to bold }
for I := 0 to slStateList.Count -1 do
begin
if SelLength <> 0 then
iStart := SelStart + SelLength
else
iStart := 0;

iEnd := Length( RichText ) - iStart;
lFoundAt := FindText( slStateList[I],iStart,iEnd,[]);

if lFoundAt <> -1 then
begin
SelStart := lFoundAt;
SelLength:= Length(slStateList[I]);
SelAttributes.Style := [fsBold];
end; // lFoundAt

end; // slStatelist

{ Set the text to Arial 10 }
SelectAll;
SelAttributes.Size := 10;
SelAttributes.Name := 'Arial';

{ Set the Tab Stops ( the actual tabs are embedded in the string) }
Paragraph.TabCount := 3;
Paragraph.Tab[0] := 150 ;
Paragraph.Tab[1] := 300 ;
Paragraph.Tab[2] := 450;
end;

This works fine in the print preview but in the actual print out only the
Tabs, Size work; I don't know what the font is but the whole thing is bold!
If I place the code for setting the font,size at the beginning of the
procedure the Tabs don't work!
If I place the code for setting the font,size, and tabs at the beginning of
the procedure nothing works!
If is use SelStart and SelLength instead of SelectAll the font, size and
Tabs work but the Style [fsBold] doesn't!

I've never run into a situation where the placement of code had such a
dramatic affect. How can I make the seemingly simple procedure work?!!

Comments

  • edited August 2001
    What verion of RB are you working with?

    Ed Dressel
    Team DM
  • edited August 2001
    6.01


  • edited August 2001
    I took demo #29 and it has bolding and underlining, so I added tabs and tab
    stop positions to it and changed the font size. It all previews fine and
    prints fine.

    So, your OnPrint works when the report is preveiwed. What happens if you
    set Report.Showmodal to false so that it prints to the printer. This should
    cause it to print correctly. You could also try setting CachePages to
    false, so that the pages aren't regenerated for the printer, since they are
    already generated for the screen using the default printer.

    The rich text manipulation works just the same as if you were working with a
    TRichEdit control, since this is the default implementation.

    What happens when you trace through the OnPrint code when printing to the
    printer? You should be able to see if there is a length of text which is
    selected when setting the attributes.

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited August 2001
    This is the first time I've used any RichText control. To set the
    Report.Showmodal to false would be against my clients wishes and doesn't
    really solve the problem. CachPages is already set to false. I have traced
    though the code and a length of text was selected this, however, did lead me
    to the following conclusion:

    After 6 frustrating hours I've discovered that what was happening was that
    when I set the Style to [fsBold] is was keeping everything there after bold
    instead of just the selected text. What I did then, was after setting the
    State to bold is set everything else up to the next occurence of State to
    []. This solved that problem. Why everything esle was happening I don't
    know.

    Now I have worked out that problem, a new one has arisen. When I set the
    DeviceType to dtReportTextFile the contents of the RichText component
    doesn't export!!!!!.


  • edited August 2001
    It isn't currently supported when printing to a text file device. We've
    added support for memos, but not rich text, yet. It is on the todo list.
    You'll need to copy your report and create one which is specifically
    designed to print to the text device. Instead of using a richtext control,
    use a memo. One customer has reported:

    Set TppReport.PrinterSetup.PrinterName to "Screen". At that point you can
    choose the "Courier" screen font (you may have to exit Delphi and get back
    in before it shows up). Set all of your text to Courier (screen font) 12
    point and everything seems to work just peachy, at least from what I've been
    able to tell.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.