InputObject Method

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

Applies to

IWPTextCursor

Declaration

int InputObject(TextObjTypes ObjType, string Name, string Command, int Mode)

Description

Creates different object kinds at cursor position. It can be used to create a single object and an object pair.

 

Note: If you need to create a "text object" you can also use InputFieldObject, for mail merge fields use InputField.

 

Parameters

ObjType

TextObjTypes:

0=(default, will create "text object")  

1=merge field,

2=hyperlink,

3=bookmark,

7=text object,

8=page reference,

11=footnote,

12=image, text box or other classes (see name)

13=horizontal lines (use IWPTextObj.SetProp(19, color) to change the color)

Name

The name of the new object.

This can be the name of a page reference, bookmark or mail-merge field.

"Text objects" can use the following predefined names:

'PAGE', 'NEXTPAGE', 'PRIORPAGE', 'NUMPAGES', 'DATE', 'TIME' and 'SECTIONPAGES'. You can use other names but then have to use the event OnTextObjectGetText to provide the text which should be actually displayed.

 

If You specify ObjType=12 You can specify a custom obj class name here. Please ask WPCubed for availability and customization of special objects.

Command

The command parameter of the new object.

Hyperlinks use this parameter as url.

Mode

If bit 1 is set an object pair will be created. The cursor will be placed within both objects.

Bit 2 activates the "editable" mode used for form fields. This must be combined with ObjType=1

Returns

0 if not successful. Otherwise the interface CurrObj can be used to change object properties.

Enum TextObjTypes:

 

Public Enum TextObjTypes

{

   wpobjCustom, // undefined

    // This objects are usually used pairwise

    wpobjMergeField, // Name=fieldname

    wpobjHyperlink, // Name=Title, Command = url

    wpobjBookmark, // Name=bookmark name

    wpobjTextProtection, // reserved

    wpobjSPANStyle, // Special texts styles 

    wpobjCode, // reserved

    // This objects are usually used singular

    wpobjTextObject, // A Text Object field (one char Text, such As PAGE), Command=Mask)

    wpobjReference, // A Text Object field (Name=Bookmark, Command=Default Text

    wpobjPageSize, // reserved

    wpobjPageProps, // reserved

    wpobjFootnote, // Only used with premium license. Name = name of text layer (RTFDataBlock)

    wpobjImage, // an image

    wpobjHorizontalLine // a line (CParam=width, IParam = margin offset)

}

 

Example:

 

This code inserts page numbering objects:

 

     IWPTextCursor TextCursor;

     TextCursor = WpdllInt1.Memo.TextCursor;

     TextCursor.InputObject(TextObjTypes.wpobjTextObject, "PAGE", "", 0);

     TextCursor.InputText("/");

     TextCursor.InputObject(TextObjTypes.wpobjTextObject, "NUMPAGES", "", 0);

 

This code inserts a blue thick line

 

          IWPMemo Memo = wpdllInt1.Memo;

          IWPTextCursor Cursor = Memo.TextCursor;

           Cursor.InputObject(13, "", "", 0);

          IWPTextObj obj = Memo.CurrObj;

          if (obj != null)

           {

               obj.SetProp(34, "blue"); // Set color value

               obj.SetProp(32, "-760"); // margin offset (outside of margins)

               obj.Height = 70;

           }

 

 

 

 

 

 

 


[idh_iwptextcursor_inputobject.htm]    Copyright © 2007 by WPCubed GmbH