IWPAttrInterface Interface |
[Top] [Chapter] [Previous] [Next] |
This important interface is used to update the character attributes and paragraph attributes.
CurrStyleAttr is used to change the character attributes defined by a style. You can use SelectStyle to create a new paragraph style or select an existing style to be modified. To apply a style a style to a paragraph, you can use the property StyleName.
The interface IWPAttrInterface has several methods to read and write properties, i.e. AttrGet and AttrSet. These methods expect the property ID (WPAT...) - Please see the list of the available WPAT codes. If the AttrGet function returns the value false, the value has not been defined. This means the inherited or the default value will be used for this property.
The property CharAttrIndex represents the writing mode as index into the attribute cache. The value can be used with TextCursor.InputText("some text", x). You can store it into an integer variable if you need to temporarily change the writing mode. When you are done simply assign the value and you can use the previous writing mode. Please note that clearing the text makes the index values invalid!
IWPAttrInterface Example
This C# example code creates text to show the possible underline modes. string[] cnames = new string[] [OBJECT] { "WPUND_Standard" [OBJECT] , "WPUND_Dotted" , "WPUND_Dashed" , "WPUND_Dashdotted" , "WPUND_Dashdotdotted" , "WPUND_Double" , "WPUND_Heavywave" , "WPUND_Longdashed" , "WPUND_Thick" , "WPUND_Thickdotted" , "WPUND_Thickdashed" , "WPUND_Thickdashdotted" , "WPUND_Thickdashdotdotted" , "WPUND_Thicklongdashed" , "WPUND_Doublewave" , "WPUND_WordUnderline" , "WPUND_wave" , "WPUND_curlyunderline" }; IWPMemo Memo = WPDLLInt1.Memo; IWPAttrInterface CurrAttr = Memo.CurrAttr; IWPTextCursor TextCursor = Memo.TextCursor; Memo.Clear(false,false); CurrAttr.Clear(); CurrAttr.SetFontface("Verdana"); //150% Line Height CurrAttr.AttrSET((int)WPAT.LineHeight, 150); int m = 1; foreach (string s in cnames) { TextCursor.InputParagraph(0, ""); CurrAttr.SetUnderlineMode(m); CurrAttr.SetUnderlineColor(WPDLLInt1.ToRGB(Color.Red)); TextCursor.InputText(m.ToString()); TextCursor.InputText(" = "); TextCursor.InputText(s); m++; } Memo.Reformat(); |