|
Programming Overview/QuickStart |
Top Previous Next |
|
This topic should help you to find the correct procedures and properties in the reference manual when you start programming with WPTools. Please note that the reference defines categories. When you found one property you can browse the list of topics in the same category (link to list of all categories).
Modify the look and feel of the editor Please use the properties ViewOptions, EditOptions and EditOptionsEx. The properties FormatOptions and FormatIOptionsEx change how the formatting routine works, they have a significant influence on how the text appears. Please also see the Layout Catagory.
Change current writing mode See property WPRichText.CurrAttr, here you can set attributes such as Bold, Italic etc. using AddStyle and DeleteStyle. CurrAttr also controls the paragraph attributes (Alignment) indents and spacing. CurrAttr will change the current writing mode or the selected text - if text is selected. See this FAQ if you want to implement ShortCuts, such a Ctr+B = bold. WPTools 5 also has more specialized attribute interfaces. They can be used to only change the current attribute, only the selected text, the attributes of the text which was found by "Finder" or the attributes of merged text. (Attribute Interface Category)
Move the Cursor Please use the CP.. properties. CPPosition is the current character position, assign 0 to go to the start, MaxInt to go to the end. Also procedure MovePosition is very useful.
Change Page Size and Page margins Modify WPRichText.Header. The properties with "default" in their name are the values which will be applied by Clear, the others are the current values. Method SetPageWH can be used to set several values at once, the values which should not be changed can be passed as -1
Insert Text Use the method InputString() to insert text at cursor position. The char codes #13 will create a new paragraph, #12 a new page. To create a table use TableAdd(). Also see the chapter Set Attributes In Code.
Mail Merge /replace fields with data) This is done by once procedure, MergeText and the event OnMailMergeGetText. If you have a text with fields marked with special characters (<name>) use method ReplaceTokens. Otherwise crate fields with method InputMergeField. Note, that mail merge fields are embedded into two instances of the TWPTextObj class. This FAQ shows how to work with images. Note: If you need to print (or export to PDF) the text right after the merge process you need to call ReformatAll(false, true)!
Input TextObjects (i.e. page numbers) This objects can be create with InputTextField(type) and InputTextFieldName(name). All text objects can show custom text which is define by event OnTextObjectGetTextEx. Custom text objects will usually display the text assigned to their property Params.
Create an own toolbar If you decide to not use the toolbar we provide please open unit WPCtrRich.PAS and check out method OnToolBarIconSelection. This method is executed for all toolbar button clicks and WPTools actions. You can see how things are done. You can also call this method from "outside".
Save and load HTML HTML is autotected when using the LoadFromFile or LoadFromStream methods. Images must be directly linked to local files. Otherwise the image must be loaded in the event OnRequestHTTPImage. (This event is also execoted for images in RTF files which have not been embedded but just linked.) Also see this FAQ and the info about format strings.
Get and set the text "as string" Use the property AsString - you can use SelectionAsString to read only the selected text. You can also assign text - the property SelectionAsString will insert the text at the cursor position. The function AsANSIString will work like property AsString but you can specify the format string, optionally only save the selection. Also see the load & save category.
Also see:
|