I am noticing odd but predictable behavior using a TWPRichText component in 5.20.8. I'm wondering if maybe I'm doing something wrong (or I'm missing a procedure call). Here is some background information:
- An Editor component on a form with a dropdown menu to select between 8 different letters.
- DropDown's OnChange event saves the currently loaded text using SaveToStream and then loads the newly selected text using LoadFromStream into the same editor component. (i.e. there is only one "editor" component on the form)
Behavior:
Every time the Editor component is loaded from stream, I run the following code.
Editor.DefaultAttr.SetFontName('Arial');
Editor.DefaultAttr.SetFontSize(10);
Editor.CPPosition := 0;
Editor.TextCursor.GetCharAttr;
Editor.CurrentCharAttr.GetFontSize(lFontSize);
The second time the editor is loaded with any text, lFontSize becomes 0 and the toolbar is blank. This only happens if the font size happens to be the same size as the default font size. If I make a modification to the font size of the text at CPPosition := 0 to, say, 17, it loads fine every time, not just the first time. If the font size of the text at CPPosition := 0 is the same as Editor.DefaultAttr, CurrentCharAttr.GetFontSize(lFontSize) returns 0!
Right before loading from stream, I am calling Editor.Clear().
Does anybody know if I'm forgetting to call some other procedure? Is there anything else that needs to be reset?