IWPParInterface Interface

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

Low level paragraph text and attribute access


The IWPParInterface makes it possible to manipulate text styles and paragraphs.


If you use it to add text (instead of IWPTextCursor functions) the new text can be creation without the need to move the cursor position. This can be useful to create text "on the fly" in headers or footers (see IWPDataBlock.AppendParagraph).


If You use Memo.CurrPar usually only the current paragraph, the paragraph the cursor is in, will be modified. But many methods and properties can also modify all selected paragraphs.


To do so, You first need to call SetProp(1,1) and when done SetProp(1,0). We highlighted the methods with this ability with this symbol: workswithseltext


This codes appends text to the paragraph:


IWPAttrInterface atr = wpdllInt1.AttrHelper;

IWPParInterface par = memo.CurrPar;

// Append normal text


par.AppendText("Normal ", atr.CharAttrIndex);

// bold text


par.AppendText("and bold", atr.CharAttrIndex); 


IWPParInterface is used to change the properties of a paragraph:


IWPParInterface par= Memo.CurrPar;

par.IndentLeft = (int)(3/2.54*1440); // Indent left = 3 cm

par.IndentRight = (int)(1.5*1440); // Indent right = 1.5 inch


In a data bound editor you need to set the modified flag prior to the change of the text. You can use

the method TextCursor.CheckState(10) to do it. This will trigger the PropChange event.


IWPParInterface is also used to change a style element.


WPDynamic.IWPParInterface style;

int i;

// create a new style


// get interface to change the style

style = wpdllInt1.Memo.CurrStyle;

// set properties in stlye

style.Alignment = 2;

// select the style for the current paragraph

wpdllInt1.CurrPar.StyleName = "New_Style";


If you need to change the NextStyle property of a paragraph style please use ConvertTextToValue:


   // Interface to modify the properties of the style

   WPDynamic.IWPParInterface style = wpdllInt1.Memo.CurrStyle;

   int i;


   // Create style 1


   style.Alignment = 1;

   // Set NextStyle property

   i = style.ConvertTextToValue("Style2");

   style.ParASet((int)WPAT.STYLE_NEXT_NAME, i);


   // Create style 2


   style.Alignment = 2;


Tip: A table row can be duplicated using the CurrPar interface. Here we first let the CurrPar interface modify the current row and then call Duplicate():

Cursor.CPTableRowNr = 1// goto row 1

Memo.CurrPar.SetPtr( Cursor.CPRowPtr );

while(rowcount-->0) Memo.CurrPar.Duplicate();



It is possible to assign a name to a paragraph using ParStrCommand(4,0,name)


The cursor can be moved to a name paragraph using TextCursor.


Please note that the interface referenced by CurrPar can change for different paragraphs.



This demo will create some random text with increasing font sizes:



    for (int i = 0; i < 30; i++)


           Memo.TextCommand(31, 1);

           Memo.CurrPar.ParASet((int)WPAT.CharFontSize, (i + 1) * 200);











[idh_interface_iwpparinterface.htm]    Copyright © 2007 by WPCubed GmbH