TRichEdit5

Source: source/classes/triched5.prg

Inherits from: TControl

TRichEdit5 wraps the Windows RichEdit 5.0 control (RichEdit50W window class), providing advanced rich text editing with support for RTF formatting, syntax highlighting, table insertion, inline pictures, spell checking, printing, and PDF export. It is suitable for building full-featured text editors and code editors within FiveWin applications.

Key DATA Members

DATATypeDescription
cFileNameCharacterLoaded file name
nRTFSizeNumericMaximum RTF text size limit
lReadOnlyLogicalRead-only mode
lHighlightLogicalEnable syntax highlighting
aKeywords1ArrayFirst keyword set for syntax highlighting
aKeywords2ArraySecond keyword set for syntax highlighting
lBarLogicalShow built-in formatting toolbar
oBarObjectBuilt-in toolbar object
lSpellLogicalEnable spell checking
nClrNumberNumericSyntax color for numbers
nClrStringNumericSyntax color for strings
nClrCommentNumericSyntax color for comments
nClrKey1NumericSyntax color for first keyword set
nClrKey2NumericSyntax color for second keyword set

Methods

MethodDescription
New( nTop, nLeft, bSetGet, oWnd, nW, nH, oFont, lPixel, cMsg, lHScroll, lReadOnly, bWhen, bValid, bChanged, lDesign, lHighlight, cFileName, nRTFSize, lNoURL, lNoScroll, lNoBorder, nLeftMargin, lNew, lBar )Create a new TRichEdit5 control
ReDefine( nId, ... )Redefine from dialog resource
LoadRTF( cRTF, lTxt )Load RTF or plain text content
SaveAsRTF() / cText( cText )Get or set the control content as text
InsertTable( nRows, nCols )Insert a table at the cursor position
InsertPicture5( cFile, nSizeX, nSizeY )Insert a picture from file
InsertBitmap( hBitmap, nSizeX, nSizeY, lSpecial )Insert a bitmap handle
SetBold() / SetItalic() / SetUnderline() / SetStrikeOut()Toggle character formatting on selection
SetAlign( nAlign )Set paragraph alignment
SetIndent( nIndent )Set paragraph indentation
Find( cFind, lDown, lCase, lWord )Search for text in the document
ReplaceAll( lUndo, cFind, lDown, lCase, lWord, lAll, cText, lMsg )Find and replace all occurrences
Cut() / Copy() / Paste() / Undo() / ReDo()Standard clipboard and undo operations
SaveToPDF( cFile )Export document to PDF
Print( cName )Print the document
Preview( cName, lModal )Show print preview
HighLightAllText()Re-apply syntax highlighting to entire document
ImportExcel( nOp, nH )Import Excel worksheet content
ImportWord( nOp )Import Word document content
ImportHtml( cFile )Import HTML file
RtfBarEdit()Show or manage the built-in formatting toolbar
Colorize( nStart, nEnd, nColor )Apply color to a range of text
GetSelection() / GetSel() / SetSel() / SetPos()Selection and cursor position management
GetZoom() / SetZoom( nNum, nDen )Zoom level control
GetLine( nLine ) / GetRow() / GetCol()Line and position query methods

Example: RTF Editor

#include "FiveWin.ch"

function Main()

   local oWnd, oRE

   DEFINE WINDOW oWnd TITLE "RichEdit 5.0 Editor" SIZE 800, 600

   @ 10, 10 RICHEDIT5 oRE VAR "" ;
      OF oWnd ;
      SIZE 760, 540 ;
      HIGHLIGHT ;
      BAR ;
      FILE "document.rtf"

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

See Also