TDBWPRichText save with TextPosition stays

  • Hi,

    when I save the text with requery I want to keep CursoPosition and Textplacement in the frame the same. With GetPosition and SetPosition the cursor stays and with TopOffset the text stays in the same position. BUT when I use both, it often doesn't work.

    Does someone has an idea how to solve this?
    Thanks
    Lothar

    Source code:

    TopOffs := WPRichTextContent.TopOffset;
    WPRichTextContent.GetPosition(pos, lin, par, pos_in_par);
    BetterAdoDatasetContent.ParamByName['Quellenangabe_ID'].value := Value;
    BetterAdoDatasetContent.requery([eoAsyncFetchNonBlocking]);
    if dxPageControlEditor.ActivePage = dxTabSheetSource then
    begin
    LoadSource;
    end;
    WPRichTextContent.SetPosition(pos, lin, par, pos_in_par);
    WPRichTextContent.TopOffset := TopOffs;

    • Offizieller Beitrag

    The absolute position means something different for diufferent texts, it depends on the length of the lines where the position in the frame will be. You can compare the position only for the same text.

    I suggest to use property CPPosition, function GetPosition does not have any advantages anymore since 'lin' is just virtual now.

    You also use SetFocus.

    Julian Ziersch

  • I'm sory, I have posted my question in WPtools 5 instead of WPtools 4.
    Is that the reason why your CPPosition doesn't work the way I need it?

    I just would like that the same part of text is shown after saving the whole text. Now after saving it often shows a different part of the text depending of length and position.

    thank you
    Lothar

  • Thank you for your patience.

    It works now with SetPosition and TopOffset.

    Because after saving it changed the FontSize (I asked about that 10 days ago, and your answer with DefaultFont and Loaded didn't help) I had to reset the FontSize again. And because I used SetPosition and TopOffset in between with the smaller FontSize, of course it didn't work always.

    So, thank you
    Lothar