WPCubed Product Support

Inserting graphics by code?

I'd like to insert graphics into a WPRichText.
(The graphics are generated by the App dynamically - bitmap-graphics or wmf vector graphics. The text holds tags that are replaced by these graphics)

Now there seem to be various ways to do that, e.g.

// Prepare graphicgra:=TBitmap.Create;gra.LoadFromFile(AppPath+'monitor_64.bmp');  // just a sample, in reality this is painted somewhere...wpimg:=TWPOImage.CreateImage(WPRichText1.Memo.RTFData, gra);// code specific for this solutionwpimg.WidthTW :=1000;wpimg.HeightTW:=1000;WPRichText1.TextObjects.Insert(wpimg);

or

// first 4 lines as in the 1st sample

wptobj:=WPRichText1.TextObjects.InsertNewObject(wpobjImage);
wptobj.ObjRef:=wpimg;
// object size is ignored - needs to be set here
wptobj.Width :=1000;
wptobj.Height:=1000;

What's the difference, which one is recommended and is there a better way to do that?

Thanks!

#1 ♥ 0
3.4k Views 2 users read 1 min
support

Hi,

both do basically the same. I would recommend
WPRichText1.TextObjects.Insert(wpimg);

Julian

#2 ♥ 0
This category is archived. No new posts are possible.