RichEdit Ocx

Purpose

Creates an Ocx RichEdit control in the current active form, window, or dialog.

Syntax

Ocx RichEdit name = text$ [, id], x, y, b, h [, style%]

text$:control text
id%:control identifier
x, y, b, h:iexp
style%:the control styles

Description

The RichEdit control allows the user to enter and edit text while also providing more advanced formatting features than the conventional TextBox control.

The RichEdit control provides a number of properties you can use to apply formatting to any portion of text within the control. To change the formatting of text, it must first be selected. Only selected text can be assigned character and paragraph formatting. Using these properties, you can make text bold or italic, change the color, and create superscripts and subscripts. You can also adjust paragraph formatting by setting both left and right indents, as well as hanging indents.

The RichEdit control opens and saves files in both the RTF format and regular ASCII text format. You can use methods of the control (LoadFile and SaveFile) to directly read and write files, or use properties of the control such as SelRTF and TextRTF in conjunction with GFA-BASIC 32's file input/output statements.

To print all or part of the text in a RichEdit control use the SelPrint method.

The RichEdit control supports almost all of the properties, events, and methods used with the standard TextBox control, such as MaxLength, MultiLine, ScrollBars, SelLength, SelStart, and SelText. Applications that already use TextBox controls can easily be adapted to make use of RichEdit controls.

Note: With TextBox - in this instance, given the name tb - it is possible to get the text by using the shortcut text$ = tb; similarly, it is possible to manipulate and/or check the text using the functions Len(), Left(), Right(), etc. This does not work with a RichEdit control as the value returned contains all the RTF formatting as well and may cause an error. To use the actual unformatted text, the Text and TextLength properties should be used instead.

Properties

Appearance | BackColor | BorderStyle | BulletIndent | CharFormat | DefCharFormat | DisableNoScroll | Enabled | Font | FontBold | FontItalic | FontStrikethru | FontUnderline | FontName | FontSize | ForeColor | FormatDC | FormatWidth | Height | HelpContextID | HideSelection | hWnd | Index | Left | Locked | MaxLength | MouseCursor | MouseIcon | MousePointer | MultiLine | Name | ParaFormat | Parent | ReadOnly | ScrollBars | SelAlignment | SelBold | SelBullet | SelCharOffset | SelColor | SelFontName | SelFontSize | SelHangingIndent | SelIndent | SelItalic | SelLength | SelProtected | SelRightIndent | SelRTF | SelStart | SelStrikeout | SelTabCount | SelTabs | SelText | SelLine | SelUnderLine | TabStop | Tag | Text | TextLength | TextRTF | Top | ToolTiptext | Visible | WantSpecial | WhatsThisHelpID | Width

Methods

DoClick | CharFromLine | ColFromChar | Find | GetLineFromChar | LineCount | LineFromChar | LoadFile | Move | Refresh | RowFromChar | SaveFile | SelPrint | SelPrintRect | SetFont | Scroll | ScrollCaret | Span | TextHeight | TextWidth | UpTo | ZOrder

Events

Change | Click | DblClick | GotFocus | LostFocus | KeyDown, Keyup | KeyPress | MouseDown | MouseUp | MouseMove | Protected | SelChange

Example

Ocx RichEdit rtf = "", 10, 10, 300, 200 : .BorderStyle = 3

rtf.SelText = String( 5, "GFA-BASIC 32 ")

rtf.SelItalic = 1

rtf.SelText = String( 5, "GFA-BASIC 32 ")

rtf.SelBold = 1

rtf.SelText = String( 5, "GFA-BASIC 32 ")

rtf.SelItalic = 0

rtf.SelText = String( 5, "GFA-BASIC 32 ")

Ocx RichEdit rtf_copy = "", 320, 10, 300, 200 : .BorderStyle = 3

Do : Sleep : Until Me Is Nothing

Shortcut Keys

The RichEdit control comes with in-built shortcut keys which are listed on the Microsoft website and a list of which are copied below. It should be noted that not all keyboard configurations will support all shortcuts, as it should also be noted that, on some keyboards, the shortcut keys may be different due to different key layout (for example, on some keyboards, Ctrl+# is used for acute accents and Ctrl+' for grave, rather than Ctrl-' and Ctrl-` as noted below).

KeysOperationsComments
Shift+BackspaceGenerate a LRM/LRM on a bidi keyboardBiDi specific
Ctrl+TabTab
Ctrl+ClearSelect all
Ctrl+Number Pad 5Select all
Ctrl+ASelect all
Ctrl+ECenter alignment
Ctrl+JJustify alignment
Ctrl+RRight alignment
Ctrl+LLeft alignment
Ctrl+CCopy
Ctrl+VPaste
Ctrl+XCut
Ctrl+ZUndo
Ctrl+YRedo
Ctrl+'+' (Ctrl+Shift+'=')Superscript
Ctrl+'='Subscript
Ctrl+1Line spacing = 1 line.
Ctrl+2Line spacing = 2 lines.
Ctrl+5Line spacing = 1.5 lines.
Ctrl+' (apostrophe)Accent acuteAfter pressing the short cut key, press the appropriate letter (for example a, e, or u). This applies to English, French, German, Italian, and Spanish keyboards only.
Ctrl+` (grave)Accent grave See Ctrl+' comments.
Ctrl+~ (tilde)Accent tildeSee Ctrl+' comments.
Ctrl+; (semicolon)Accent umlautSee Ctrl+' comments.
Ctrl+Shift+6Accent caret (circumflex)See Ctrl+' comments.
Ctrl+, (comma)Accent cedillaSee Ctrl+' comments.
Ctrl+Shift+' (apostrophe)Activate smart quotes
BackspaceIf text is protected, beep and do not delete it. Otherwise, delete previous character.
Ctrl+BackspaceDelete previous word. This generates a VK_F16 code.
F16Same as Backspace.
Ctrl+InsertCopy
Shift+InsertPaste
InsertOverwriteDBCS does not overwrite.
Ctrl+Left Arrow Move cursor one word to the left.On bidi keyboard, this depends on the direction of the text.
Ctrl+Right ArrowMove cursor one word to the right.See Ctrl+Left Arrow comments.
Ctrl+Left ShiftLeft alignmentIn BiDi documents, this is for left-to-right reading order.
Ctrl+Right ShiftRight alignmentIn BiDi documents, this is for right-to-left reading order.
Ctrl+Up ArrowMove to the line above.
Ctrl+Down ArrowMove to the line below.
Ctrl+HomeMove to the beginning of the document.
Ctrl+EndMove to the end of the document.
Ctrl+Page UpMove one page up.If in SystemEditMode and Single Line control, do nothing.
Ctrl+Page DownMove one page down.See Ctrl+Page Up comments.
Ctrl+DeleteDelete the next word or selected characters.
Shift+DeleteCut the selected characters.
EscStop drag-drop.While doing a drag-drop of text.
Alt+EscChange the active application.
Alt+XConverts the Unicode hexadecimal value preceding the insertion point to the corresponding Unicode character.
Alt+Shift+XConverts the Unicode character preceding the insertion point to the corresponding Unicode hexadecimal value.
Alt+0xxx (Number Pad) Inserts Unicode values if xxx is greater than 255. When xxx is less than 256, ASCI range text is inserted based on the current keyboard. Must enter decimal values.
Alt+Shift+Ctrl+F12Hex to Unicode.In case Alt+X is already taken for another use.
Alt+Shift+Ctrl+F11Selected text will be output to the debugger window and saved to %temp%\DumpFontInfo.txt.For Debug only (need to set Flag=8 in Win.ini)
Ctrl+Shift+A Set all caps.
Ctrl+Shift+L Fiddle bullet style.
Ctrl+Shift+Right Arrow Increase font size.Font size changes by 1 point in the range 4pt-11pt; by 2points for 12pt-28pt; it changes from 28pt -> 36pt -> 48pt -> 72pt -> 80pt; it changes by 10 points in the range 80pt - 1630pt; the maximum value is 1638.
Ctrl+Shift+Left Arrow Decrease font size.See Ctrl+Shift+Right Arrow comments.

See Also

Ocx, OcxOcx, LoadRichEdit50W.

Animation, CheckBox, ComboBox, Command, CommDlg, Form, Frame, Image, ImageList, Label, ListBox, ListView, MonthView, Option, ProgressBar, Scroll, Slider, StatusBar, TabStrip, TextBox, Timer, TrayIcon, TreeView, UpDown

{Created by Sjouke Hamstra; Last updated: 25/08/2021 by James Gaite}