Home Component Writing

Subclassing TppDBRichtext

edited December 2015 in Component Writing
Hi,

we have a component that inherits from TppDBRichtext.
On Creating the component we set caption:='Adam'.
Within the designer a box with the caption is draw.
Setting some properties allows us to read a rtf-string from our
database within "ongetRichtext".
The richtext is succesfully read from database, but
self.richtext=dbdata or self.text=dbdata doesnot work.
The component still displays its caption.

1.) What is the relation between caption,text and richtext?
2.) Is my rtf string wrong:

'{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Segoe
UI;}{\f1\fnil Segoe UI;}}'#$D#$A'{\*\generator Msftedit
5.41.21.2510;}\viewkind4\uc1\pard\lang1031\ul\i\f0\fs18
Non-\ulnone\i0\par'#$D#$A'\b sens\b0\f1\par'#$D#$A'}'#$D#$A#0

We are trying to use RB16.03, coming from 5.56 this code worked n
fomrer times

Any ideas?

Comments

  • edited December 2015
    Hi Carsten,

    1.

    The RichText property represents the raw RTF data and is what you will
    want to use.

    The Text property is inherited from TppPrintable and is not used for
    RichText.

    The Caption property is the text displayed when no RTF data is present
    in the RichText control.

    2.

    At first glance, your RTF data looks valid. Try tracing into the
    TppCustomRichText.SetRichText routine and see if you data is actually
    being saved to the component. This routine is located in the
    ppRichTx.pas file.

    My guess is that this is a timing issue. Where/when are you setting the
    RTF data? If you are descending from DBRichText, why not simply connect
    the component to the RichText DB field and let ReportBuilder take care
    of loading the data?


    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2015
    Hi Nico

    where is the code where the decision is made if no rtftext is present
    and caption has to be drawn? I did not find i, i would like do debug
    this code!

    Setting RTF:
    There is OnGetRichText := MyOnGetRichText; within the constructor
    MyOnGetRichText is called and the rtf-strings are retrieved from the
    database

    The second call is made after changing the text:
    MyOnGetRichText(Sender, TheText);
    self.RichText:=TheText;


    Delegating to Richtextdb:
    Database access is a bit difficult within our application.
    I am just migrating from RB 5.56 to 16.03 and trying to make as little
    changes to the existing code, both ours and yours, to get things work
    again!


  • edited December 2015
    Hi,

    doing

    theText:='{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0
    Segoe UI;}{\f1\fnil Segoe UI;}}'#$D#$A'{\*\generator Msftedit
    5.41.21.2510;}\viewkind4\uc1\pard\lang1031\ul\i\f0\fs18
    Non-\ulnone\i0\par'#$D#$A'\b sens\b0\f1\par'#$D#$A'}'#$D#$A#0

    self.richtext:=thetext;
    lthetext:=self.richtext

    result in lthetext=''

    From my point of view the rtf is not correct! Parsing fails!

    Tia
    Carsten

    Nico Cizik (Digital Metaphors) formulierte Donnerstag :
  • edited December 2015
    Hi Carsten,

    As I mentioned in #2 of my previous post, try tracing into the
    TppCustomRichText.SetRichText routine and see if you data is actually
    being saved to the component. This routine is located in the
    ppRichTx.pas file and is where ReportBuilder verifies the RTF data.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2015
    By chance i discovered what is the difference to 5.56:

    In 5.56 rtf-values are displayed both in design and preview window.
    In 16.03 i get caption in design-mode and rtf in preview mode
    Upto now I did not find the code where this difference is made for
    displaying on screen. Any hints?

    As far as I understood our old code, a dbrichtext has not to be used as
    the text to be used is stored within a database but does not change on
    runtine/printing.
    A Richtext should fullfill all requirements!

    Tia Carsten


    Am 04.12.2015, Nico Cizik (Digital Metaphors) vermutete :
  • edited December 2015
    Hi Carsten,


    This is incorrect, the behavior in RB 16.03 is identical to that which
    you describe for RB 5.x. You can perform a simple test with a separate
    application:

    Place a TppRichText or TppDBRichText on an empty report and assign it
    some RTF data (either manually or with a DB field). When you return to
    the design window, the RTF text will be displayed in the designer.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.