I am trying to add styles support to our RTF Editor, based on TWPRichText. We can't use your own Style combobox, due to design differences, so I had to implement our own. And I am experiencing problems.
My control is simple, I am offering user a set of 7 predefined styles, without ability to rename them, add new, etc.
At the start I create this style list using a code like this:
sty: TWPTextStyle; ... Editor.ParStyles.Clear; for i := Low(FStyles) to High(FStyles) do begin sty := Editor.ParStyles.AddStyle(FStyles[i].Name); sty.ASetFontName(FStyles[i].FontName); sty.ASet(WPAT_CharFontSize, 100 * FStyles[i].FontSize); if FStyles[i].Bold then sty.ASetAddCharStyle(WPSTY_BOLD); ... end;
Then I am trying to set a default style to one of them with
When user selects a style via combobox I run this code:
Editor.CurrAttr.StyleName := StyleNameCombobox.Text;
EditorCharacterAttrChange(Self, nil); // to show font name, size, etc.
Editor.ReformatAll(true);
Editor.Repaint;
I also have separate combos for Font name, size and color which worked fine from before.
It works very erratic, with styles getting lost.
What would you recommend?
Also, when user starts a new paragraph (pressing Enter), current style always gets lost and reverted to <default attributes>, in your demos as well. Is it possible for a new paragraph to always get assigned a particular style, e.g. 'Normal'?
Aleksandar Momcilovic,
Maestro Soft, Norway