<gulp> I guess I'm the first one to add an entry to this new forum...:)
Julian, please feel free to correct any misstatements I make in what follows.
In previous versions, if you wanted to fine-tune an inserted object, personalize it differently than the defaults, you might use code similar to the following:
function Form1.InsertGraphicObject( strObjFilename : string ) : boolean;var obj : TWPObject; wObj : word; pObj : PTTextObj;begin result := FALSE: obj := WPLoadObjectFromFile( Self, strObjFilename, FALSE ); if( obj = nil ) then exit; obj.Transparent := TRUE; wobj := WPRichText1.TextObjects.Insert( obj ); pObj := WPRichText1.TextObjects.TextObjectGet( wObj ); if( pObj <> nil ) then begin pObj^.wrap := wpwrLeft; pObj^.typ := wpotPar; Result := TRUE; end;end;
As you can see, start with Insert, which returns a value of type Word, which can then be passed to TextObjectGet, who would then return a pointer to a text object. That pointer would then be worked with, as shown above. It works, but it's a little Rube Goldberg-esque.
With WPTools 5, the TextObjects.Insert function has changed. It no longer returns the ID (tag) of the inserted object. Now the reference to this object is returned directly!!! Talk about clean. And that's a good thing, with pointers no longer used in WPTools5.
So the above snippet can now become simply:
function Form1.InsertGraphicObject( strObjFilename : string ) : boolean;
var
obj : TWPObject;
begin
Result := FALSE:
obj := WPLoadObjectFromFile( WPRichText1.Memo.RTFData, strObjFilename, FALSE );
if( obj = nil ) then
exit;
with WPRichtext1.TextObjects.Insert( obj ) do begin
PositionMode := wpotPar;
Wrap := wpwrLeft;
Result := TRUE;
end;
end;
Alles anzeigen
---< Notes >---
o If you still need a text object's tag/ID, get it with <TWPTextObj>.ID
o InsertNameLink, InsertName, formerly in WPTools 4, have both been replaced with <TWPTextObj>.Insert
o the Insert function now has some additional, optional parameters that you might find userful. Check it out in Help!
o in WPTools5, WPLoadObjectFromFile's first parameter type has changed. In WPTools 4 it was of type TComponent, presumably the object's owner. Now, it's of type TWPRtfDataCollection.
Hopefully that clears some things up, or might be the starting point for other WPTools users to expand on.
There's a lot of power, and elegance, new with WPTools 5. This only begins to scratch the surface.
I encourage anyone (and everyone) to please share your suggestions and solutions in this new forum Julian has created for our use. We all benefit! I look forward to seeing what others uncover, and create.
JazzMan (aka diamond)