Strange formatting when appending

  • Hello,

    I've got a behaviour in WPTools in don't understand. I'm building a very complex document out of a Database.
    A use 2 TWPRichEdits to build the Document. In one RichEdit I build blocks which I append to the other RichEdit.
    If I only build the blocks and append them together in the second TWPRichEdit everything works fine.
    But as soon as I change some formatting in the second document all the font information from the first RichEdit gets lost (except the underlined property). This only happens with Text I built in code. The text the users entered (I append some text using ->SelectionAsString = TextFromDB) stays nicely formatted, though it is also in RichEdit1.

    I use this to format my text:

    It looks like the component can't handle it if there are Cardinals from 2 different TWPRichEdits in one Document. Or is there a better way for general formatting of texts in code?

    Thanks for your help!!!

    Florian Fanderl

    • Offizieller Beitrag

    Hi,

    If you use one cha_txtplain for both TWPRichText this can only work if the use shared TWPRTFProps object. I assume this is the case.

    But here it is required to be careful with Clear()

    Please call ClearEx and make sure the styles are not deleted!

    procedure ClearEx(DontClearStyles, DontResetPageSize, ResetWritingAttr: Boolean);

    Julian

  • Is it enough if I then initialise my styles in the FormCreate Event Handler of the form?
    Should be enough if just use ClearEx and ClearBody, right?

    Appending the Document works fine now btw :) Thank you very much!!!