• I'm defining a couple of styles in code :-

    Code
    aStyle := Editor.ParStyles.AddStyle(STYLE_PLAIN);   aStyle.ASetFontName('Verdana');   aStyle.ASet(WPAT_CharFontSize, 15*100); // 15pt   aStyle := ditor.ParStyles.AddStyle(STYLE_QUOTED);   aStyle.ASetFontName('Lucida Console');   aStyle.ASet(WPAT_CharFontSize, 14*100); // 14pt

    I then try to set STYLE_PLAIN as the active style

    Code
    Editor.ActiveStyleName := STYLE_PLAIN

    But the text is rendered using the font and size from CurrAttr which is 11pt Arial. I've tried setting Editor.CurrAttr.StyleName to STYLE_PLAIN as well, but that makes no difference.

    What am I missing?

    Here's what the saved text looks like in WPT format (I've just taken the bit from the end)

    Code
    <stylesheet><pstyle name="Plain" nr=1 wpsty=[[CharFont:'Verdana';CharFontSize:1500;CharStyleMask:7;CharBGColor:clWhite;]]/>
    <pstyle name="Quoted" nr=2 wpsty=[[CharFont:'Lucida Console';CharFontSize:1400;CharStyleMask:7;CharColor:clGreen;CharBGColor:clWhite;]]/>
    </stylesheet><div><cs nr=1 wpsty=[[CharFont:'Arial';CharFontSize:1100;]]/><c nr=1/>Testing lkfj sldjf lsdjflsdljsd lksdlkf jlsjfd</div>

    Einmal editiert, zuletzt von rah99 (20. September 2004 um 11:04)

    • Offizieller Beitrag

    Hi,

    probably the current font uses the character attributes you see. WPTools will use only those attributes of styles which are not used in an element at higher level.

    So you need to clear those attributes. You can use

    CurrAttr.ClearAttributes

    with WPRichText1.ParStyle.GetID(STYLE_PLAIN ) as parameter.

    BTW.: Please avoid headlines like this.

    Julian

  • No, that didn't work.

    Tracing through there is no change whatsoever to CurrAttr.FontName or CurrAttr.Size.

    Here's the code :-

    Code
    Editor.ActiveStyleName := STYLE_PLAIN;
    		Editor.CurrAttr.StyleName := STYLE_PLAIN ;
    		Editor.CurrAttr.ClearAttributes(-1) ;
    		Editor.CurrAttr.StyleName := STYLE_PLAIN ;

    I changed it to use ClearAttributes(-1) since Editor.ParStyles.GetId(STYLE_PLAIN) didn't work either.

    Any other suggestions?

    I'll try to create a small example program that shows the same problem if that would help.

    • Offizieller Beitrag

    Hi,

    this code is executed inside WPCTRRich for the style name combobox ()or action)

    Code
    wptTyp:        begin           if (str='') or (str=WPLoadStr(meUndefinedStyle)) then                CurrAttr.StyleName := ''           else if str=WPLoadStr(meEditCurrStyle) then                OpenDialog(wpdiaEditCurrentStyle)           else if str=WPLoadStr(meCreateNewStyle) then                OpenDialog(wpdiaCreateNewStyle)           else CurrAttr.StyleName := str;        end;

    It seems to always work. ActiveStyleName is just the same as 'CurrAttr.StyleName'.

    This is the code executed for ActiveStyleName. It is interesting because of the use of the 'TextCursor' property which is responsible for all the trext changes. CurrAttr is more or less only provided for compatibility reasons, although there is no need to NOT use it - except for server procedures wher I recommend to create a TWPCusomtRTFEdit in code.

    In your case - is actually a selection defined?

    Otherwise you can also use ActivaParagraph.ASetBaseStyle


    Julian