Styles / TWPStyleCollection

  • Hi,
    I create my own form with ribbons. All works Ok except styles. After I add style for example Normal by WPStyleDlg I have this style in WPStyleCollection. I refresh Style combo by WPStyleCollection OnChangeStyleList event. It works OK, in style combo I have new style.
    But OnChane event of StyleCombo doesn't any effect:

    WPRichText.CurrAttr.StyleName := dxBarCombo1.Text;
    WPRichText.SetFocus;

    FontName Combo text property empty.
    FontSize Combo text property empty.

    Style from Style combobox isn't implemented.

    What I do wrong. I new in WPTools.

    Thanks,
    JR

    • Offizieller Beitrag

    Hi,

    the unit WPActions.PAS implements actions to work with dx comboboxes. You need to activate it there using a $define USEEXPRESSBARS

    Internally it executes this code to update the combo:

    Zitat

    if edit.ActiveStyleName = '' then
    TdxBarCustomCombo(FAttachedControl).Text :=
    WPLoadStr(meUndefinedStyle)
    else TdxBarCustomCombo(FAttachedControl).Text := edit.CurrAttr.StyleName;

    Julian

  • Hi,
    I don't use actions. In style combo I have all styles from StyleCollection. After adding new style it's adding to StyleComboBox. Problem is, that :
    WPRichText.CurrAttr.StyleName := dxBarCombo1.Text;
    don't implement this style in text. Name and size of font are equal '' (empty). Text properties of this combos are from WPRichText.TextCursor.CurrAttribute.GetFontName and
    WPRichText.TextCursor.CurrAttribute.GetFontSize.
    I think that WPRichText have property which disable styles, but I can't find it.

    Thanks for help,
    JR

    • Offizieller Beitrag

    Hi,

    the problem is that just assigning the style name does not install the style in the RTF buffer.

    Also you do not use Actions, please check out the mentioned code as example.

    The style collection has this methods to exchange the data with an editor:

    procedure ReadStyles(SourceEditBox: TWPCustomRtfEdit); overload;
    procedure WriteStyles(DestEditBox: TWPCustomRtfEdit);

    Only if You once have called "WriteStyles" the styles will excist in the editor ParStyles collection and only then you can use "StyleName".

    Julian