TextAttr

[Top]  [Chapter]  [Previous]  [Next]

Declaration

IWPAttrInterface TextAttr;

Description

This is the interface to the change the current writing (CurrAttr) attribute of the active editor unless text is selected.

In case text has been is selected the properties of the selected text (CurrSelAttr) will be updated.

To change paragraph attributes please use CurrPar.

This property is used best to apply and read the text attributes to implement a custom toolbar.

Example:

private void wpdllInt1_OnUpdateGUI(

 object Sender, 

 int Editor, 

 int UpdateFlags, 

 int StateFlags, 

 int PageNr, 

 int PageCount, 

 int LineNr)

{

         string n = "";

         wpdllInt1.Memo.TextAttr.GetFontface(ref n);

         FontCombo.Text = n;

}

 

If a function of TextAttr returns FALSE this means the default attribute is used for this property.

The default text attributes can be changed in Memo.DefaultAttr.

 

IMPORTANT:

Memo.TextAttr provides either a reference to CurrAttr or to CurrSelAttr, depending on the state of TextCursor.IsSelected. Please note, that an initialization before the selection process will cause the wrong interface to be provided.

This will code not modify the attribute of "some text":

IWPMemo Memo = wpdllInt1.Memo;

IWPTextCursor TextCursor = Memo.TextCursor;

IWPAttrInterface Attr = Memo.TextAttr;

bool ok = false;

 

int cp = TextCursor.MarkerDrop(0);

// Use FindText.- If "MoveCursor=false", the text will be selected

TextCursor.FindText("some text", true, false, false, false, ref ok);

if (ok)

{

    Attr.Clear();

    Attr.SetFontface("Arial");

}

TextCursor.MarkerGoto(true, cp);

 

 

Instead, it has to be done like this:

IWPMemo Memo = wpdllInt1.Memo;

IWPTextCursor TextCursor = Memo.TextCursor;

bool ok = false;

 

int cp = TextCursor.MarkerDrop(0);

// Use FindText.- If "MoveCursor=false", the text will be selected

TextCursor.FindText("some text", true, false, false, false, ref ok);

if (ok)

{

    IWPAttrInterface Attr = Memo.TextAttr;

    Attr.Clear();

    Attr.SetFontface("Arial");

}

TextCursor.MarkerGoto(true, cp);

 

Or You use CurrSelAttr instead

 

IWPAttrInterface Attr = Memo.CurrSelAttr;

 

 

 


[textattr.htm]    Copyright © 2007 by WPCubed GmbH