Function TWPObjectEnv.Insert(data:TPersistent; w:Integer; h:Integer; objname:string; StreamName:string) : TWPTextObj

Unit: WPRTEDefs
Class: WPRTEDefs.TWPObjectEnv

Parameters

  • data:TPersistent
  • w:Integer
  • h:Integer
  • objname:string
  • StreamName:string

Returns

The type of the result value is TWPTextObj.

Description

Insert a object at cursor position. It can be of type Image, Picture, Bitmap, Metafile, too. Then a new TWPTOImage will be created. The optional parameters are the size of the object and the name. You can also use a 'streamname' to create a link to a file. If you provide a ObjName the procedure will first try to find a TWPObject with this name and link to it before it uses 'data'.

Note: If the provided data object inherits from the TGraphic class it will be freed after it had been assigned to the automatically created . If you want to keep the graphic (maybe it was passed as Image1.Picture.Graphic) then please use the procedure instead of Insert.

If currently an image object is selected the new object will use the same wrap mode and position as the replaced image. The size will be changed to match the size of the old image while the height is modified to keep aspect ration of the new image.

Note: In an completely empty TWPRichText this function will not insert anything unless CheckHasBody has been called to make sure there is a vaild cursor position.

Upgrade notes: InsertNameLink, InsertName ... are superseeded by this function. In previous versions the ID (tag) of the object was returned, now the reference to this object is returned directly. USe TWPTextObj.ID to read the tag/id.