WrittingAttr not loading font/size from streamed template

  • Hi,

    I stream a saved template, which is a rtf document saved into a DB, which includes a bookmark called Startpoint.

    Now after loading using loadfromstream, i call BookmarkMoveTo to move the cursor to the bookmarked point which is arial 8. now when the form is displayed the toolbar combo box show the current font as arial 11, which if you starting typing is what is entered.

    Now if the arrow keys are pressed or you left click into the control, the toolbar is updated to the correct values of arial 8.

    So what i need is a way to force the toolbar or the writtingattr to recalc its settings from the loaded document.

    eg.

    Code
    Stream.Position := 0;
        FRichEditor.LoadFromStream(Stream, 'RTF",False); 
        FRichEditor.BookmarkMoveTo('Startpoint',true);


    Notes.
    Before loading this template, another is loading with the header/footer info, which is the reason for the 'False' in the loadfromstream.

    This is a cutom control, which include the following controls on a TPanel.
    FRichEditor: TWPRichText;
    FVertRuler: TWPVertRuler;
    FWPRuler: TWPRuler;
    FToolBar: TWPToolBar;
    FSpellController : TWPSpellController;

    Thanks for your help,
    Mike

    • Offizieller Beitrag

    Hi,

    I assume the problem is caused because the bookmark itself has no attribute, I suggest:

    Code
    if FRichEditor.BookmarkMoveTo('Startpoint',true) then  
    begin
      FRichEditor.CPMoveBack;
      FRichEditor.GetCharAttr; // pick up attr BEFORE bookmark
      FRichEditor.CPMoveNext;
    end;

    Julian

  • Hi Julian,

    Thanks for your help.

    Your code did not compile but pointed me in the right direction, here is the working for for other people with this issue.

    if FRichEditor.BookmarkMoveTo('Startpoint',true) then
    begin
    FRichEditor.CPMoveBack;
    FRichEditor.TextCursor.GetCharAttr; // pick up attr BEFORE bookmark
    FRichEditor.CPMoveNext;
    end;

    Thanks again
    Mike