BlockAdd Method

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

Creates or selects a header or footer text layer

Declaration

IWPDataBlock BlockAdd([In] DataBlockKind Kind, [In] DataBlockRange Range, [In] string Name, [In] int SectionID);

Description

This method is used to select an existing (with matching Range/Name) or create a new header or footer text block. An interface to the created block is returned as IWPDataBlock reference. This method works similar as TextCursor.InputHeader and TextCursor.InputFooter but will not modify the cursor position.

 

In the .NET assembly also available is

 public bool BlockAddAndWorkOn(DataBlockKind Kind, DataBlockRange Range, string Name, int SectionID)

it creates the new block and places the cursor inside.

 

Note: Please don't forget to call ReleaseInt() with the returned interface at the end of your code.

 

 

Possible Values for DataBlockKind:

0        wpIsBody,

1        wpIsHeader,

2        wpIsFooter,

3        wpIsFootnote,

4        wpIsLoadedBody,

5        wpIsDeleted,

6        wpIsOwnerSelected

 

Possible Values for DataBlockRange:

0        wpraOnAllPages,

1        wpraOnOddPages,

2        wpraOnEvenPages,

3        wpraOnFirstPage,

4        wpraOnLastPage,

5        wpraNotOnFirstAndLastPages,

6        wpraNotOnLastPage,

7        wpraNamed,

8        wpraIgnored,

9        wpraNotOnFirstPage

 

The parameters Name and SectionID are usually not required. Please pass "" and 0.

 

VB.NET Example - create a header and move the cursor inside.

     

Dim header As IWPDataBlock

header = Memo.BlockAdd(DataBlockKind.wpIsHeader, DataBlockRange.wpraOnAllPages, "", 0)

'Clears the text

header.Clear()

'Moves the cursor inside the header

header.WorkOnText = True

 

' it is required to call ReleaseInt to remove the interface

wpdllint.ReleaseInt(header)

 

This code will have the same effect: Memo.TextCursor.InputHeader(DataBlockRange.wpraOnAllPages, "", "")

 

C# Example - create a header and some text but do not move cursor:

 

IWPMemo Memo;

Memo = wpdllInt1.Memo;

 

IWPDataBlock header;

header = Memo.BlockAdd(DataBlockKind.wpIsHeader, DataBlockRange.wpraOnAllPages, "", 0);

//Clears the text

header.Clear(); 

header.AppendParagraph();

// change the default attribute for this paragraph

header.CurrParAttr.SetFontface("Courier New");

header.CurrParAttr.SetFontSize(22);

// Sets the text using the default attribute

header.CurrPar.SetText("Header text for the document", -1);

 

In case you need to append text or a text object (page numbering) using

a different style you can use the AttrHelper!

 

// Get this character index

Memo.CurrAttr.CharAttrIndex = header.CurrParAttr.CharAttrIndex;

// and modify it

Memo.CurrAttr.IncludeStyles(1); // Bold!

// append text using the current writing mode

header.CurrPar.AppendText(", bold text", -2);

 

 

 


[idh_iwpmemo_blockadd.htm]    Copyright © 2007 by WPCubed GmbH