|
Text boxes |
Top Previous Next |
|
To insert a text box use this code:
var obj: TWPORTFTextBox; txtobj: TWPTextObj; begin if WPRichText1.CursorOnText.Kind <> wpIsBody then ShowMessage('Cannot insert object in Object') else begin obj := TWPORTFTextBox.Create(WPRichText1); obj.WidthTW := 3000; obj.HeightTW := 1000; obj.ObjName := '_AUTO_' + IntToStr(GetTickCount); obj.AsString := '<b>Textbox</b> text in HTML, ANSI or RTF format!'; txtobj := WPRichText1.TextObjects.InsertMovableImage(obj); if txtobj <> nil then begin txtobj.Mode := txtobj.Mode + [ wpobjObjectUnderText, wpobjCreateAutoName ]; txtobj.RelX := 1440; txtobj.RelY := 0; // optional txtobj.Frame := [wpframe1pt,wpframeShadow]; WPRichText1.ReformatAll; obj.Edit; WPRichText1.SetFocus; end; end; end;
This code in the OnTextObjectDblClick event makes the text box editable:
if pobj.ObjType = wpobjImage then begin if pobj.ObjRef <> nil then pobj.ObjRef.Edit; ignore := TRUE; end;
Screenshot of the created box in edit mode (after double click):
Tip: To create a text box which is automatically positioned in the margin of the page use the modes wpobjLockedPos,wpobjPositionInMargin
|