And now about the additional properties and methods of the text input field with formatting (rich edit), which are much more than the properties and methods common to all edit fields.
And, first of all, I immediately draw your attention to the RE_Font property, namely, that this property should be used to change the font parameters instead of the usual Font property.
MaxTextSize - the maximum size of the text in the input field. The default is 32767 (which is the maximum possible for an unformatted text input field - memo). In order to allow entering editing of large-sized texts, this property should be changed (the maximum allowable value is 4 Gigabytes, without one byte);
RE_TextSize[units] - returns the current formatted text size in the specified units of measurement (in the units options it is even possible to specify whether to take into account the characters # 13 # 10 at the end of lines);
RE_TextSizePrecise - returns the exact size of formatted text in characters;
RE_CharFmtArea - sets the character formatting area (current selection, current word, or all text) that is used when formatting characters (RE_CharFormat, and many properties that control font styles and colors). defaults to raSelection, i.e. formatting is applied to the current selection in the text. If you change the value to raAll, then the formatting will apply to the entire content, and in the case of the value of raWord, the changes will affect only the word to which the caret is set (SelStart);
RE_CharFormat - the lowest level of access to character formatting properties. Allows you to read the current formatting (this returns the structure), change this formatting (by changing the structure fields), and assign a new value for the formatting settings to this property. It is better to use the corresponding properties below to change individual formatting settings:
RE_Font - font settings, when reading this property, the settings for the first character in the formatting area (RE_CharFmtArea) are returned, when changed, the new font is applied to the entire formatting area. Sometimes it is necessary to change only one of the formatting styles in the formatting area (for example, italic), without affecting all the others, for this you should use the properties RE_FmtItalic, RE_FmtBold and other similar properties below.
|
Note when changing the font for the rich edit control, you should be aware that the font height for this object is set in twips, not in pixels, which is 1/20 of a point, where point is a logical unit equal to 1/72 inch on the display screen ( see the font properties in the description of the TGraphicTool object). |
RE_FmtBold - style "bold" for a font in the formatting area, in order to find out if the returned value refers to all characters in the selection area or only to the first character, use the property:
And similar properties for other character styles:
RE_FmtItalic and RE_FmtItalicValid for italic font style;
RE_FmtStrikeout and RE_FmtStrikeoutValid for strikethrough style;
RE_FmtUnderline and RE_FmtUnderlineValid for the underlined style, in addition, there is an additional property for the underline:
RE_FmtUnderlineStyle - allows you to set the style of the underline (single, double, word by word, dots, dashed, wavy, mixed dash-dot, dash-dot-dot, thickened, ...);
RE_FmtProtected and RE_FmtProtectedValid - protection of a piece of text from being changed by the user;
RE_FmtHidden and RE_FmtHiddenValid - hiding a piece of text from the user;
RE_FmtLink and RE_FmtLinkValid - allows you to mark a part of the text as a link (URL - Universal Resolve Link, usually used as a link to Internet pages, and to highlight email addresses);
RE_FmtFontSize and RE_FmtFontSizeValid - font height in twips (see above);
RE_FmtFontColor and RE_FmtFontColorValid - the color of the symbols;
RE_FmtAutoColor and RE_FmtAutoColorValid - specifies that the default color for symbols is used;
RE_FmtBackColor and RE_FmtBackColorValid - background color;
RE_FmtAutoBackColor and RE_FmtAutoBackColorValid - determines that the default color for the background is automatically used for the formatting area;
RE_FmtFontOffset and RE_FmtFontOffsetValid - the offset of the font from the baseline down (negative values - up), as well as the font height, is set in twips;
RE_FmtFontCharset and RE_FmtFontCharsetValid - a set of font characters;
RE_FmtFontName and RE_FmtFontNameValid is the name of the font.
In addition to character formatting, rich edit also has paragraph (paragraph) formatting.
It applies (is set) to paragraphs that fall within the selection area (and is returned for the first paragraph in the selection area). Here the phrase "in the selection area" means even a partial hit of the paragraph in the selection area, including in the case when there is no selection - to the paragraph in which the input caret position is located.
RE_ParaFmt - similar to RE_CharFormat, provides low-level access to paragraph formatting parameters: the structure should be retrieved, modified and reassigned to this property to change the paragraph formatting parameters. Other paragraph formatting properties, when changed, affect only the corresponding formatting style, without affecting other styles;
RE_TextAlign - text alignment (left, right, center, or width). Justification is performed and is preserved in the text, but, unfortunately, it cannot be displayed by the rich edit window itself, i.e. to see that the text in the paragraph is indeed aligned along the edges, you can only save this text in an rtf file, and load it for viewing in a word processor like MS Word or Write. Similar to the character formatting properties, there is also a corresponding validation property: RE_TextAlignValid, which indicates that this formatting takes place for all paragraphs that fall into the selection area, and not only for the first paragraph;
RE_Numbering - sets the use of paragraph numbering, see also properties RE_NumStyle and RE_NumStart;
RE_NumStyle - sets the numbering style (no numbering, unnumbered list, Arabic numerals 0, 1, 2, ..., letters a, b, c, ...; letters A, B, C, Roman numerals i, ii, iii, iv , ..., and uppercase roman numerals I, II, III, IV, ...);
RE_NumStart - sets the initial number for numbering (for letter numbering, the number 1 corresponds to the letter A or a);
RE_NumBrackets - sets the separator between the numbering sign and the paragraph text (brackets on the right: 1), 2) ..., brackets on both sides (1), (2), ..., point on the right 1., 2., ..., and a regular space);
RE_NumTab - width of the field reserved for the number (if the field is too narrow, the number is not displayed);
And all these numbering properties can be checked with the RE_NumberingValid property to ensure that the numbering is the same for all paragraphs in the selected area;
RE_Level - nesting level (read-only);
RE_SpaceBefore and RE_SpaceBeforeValid - the space (vertically) before the paragraph;
RE_SpaceAfter and RE_SpaceAfterValid - the space after the paragraph;
RE_LineSpacing - interline skip within a paragraph;
RE_SpacingRule - rule (units of measurement?) for the RE_LineSpacing property, no other information;
RE_LineSpacingValid - checks that the properties RE_LineSpacing and RE_SpacingRule are the same for all paragraphs in the selection area;
RE_Indent and RE_IndentValid - left indent for text in a paragraph;
RE_StartIndent and RE_StartIndentValid - indentation for the first displayed line of text in a paragraph ("red line");
RE_RightIndent and RE_RightIndentValid - indent from the right edge of the sheet for the text in the paragraph;
RE_TabCount - the number of tab stops in the RE_Tabs array;
RE_Tabs[i] - tab stops for text;
RE_TabsValid - checks that the properties RE_TabCount and RE_Tabs are the same for all selected paragraphs;
This completes the list of formatting properties, although it is not complete yet. If you need table formatting, you can see the corresponding properties in the TControl help, or by looking at the source code in KOL.pas.
It would be better to pay more attention to other properties with the RE_ prefix:
RE_FmtStandard - calling this method attaches an additional handler for pressing the keyboard, which provides the ability to format text using control keys. For example: ctrl + B - turn bold on and off, ctrl + I - italic, ctrl + U - underlines, ctrl + O - strikethrough, ctrl + L - left alignment, ctrl + R - right align, ctrl + E - align center, ctrl + J - edge alignment, ctrl + N - numbering style selection, ctrl + '+' - font increase, ctrl + '-' - font decrease, etc .;
RE_AutoKeyboard - this property controls the automatic switching of the keyboard layout when the caret enters the text written in the corresponding language (moreover, if this property is initially enabled for rich edit windows in Windows9x, then it is disabled in Windows NT);
Note: There is also an additional design-time property RE_AutoKeybdSet for the MCK mirror TKOLRichEdit, which controls whether code should be generated to set the RE_AutoKeyboard property to ensure the same behavior of the RE_AutoKeyboard property on all operating systems. Or, on the contrary, you should not create such code, and then such behavior will be determined by the peculiarities of the OS version.
RE_OverwriteMode - turns on the "in place" recording mode, in which, from the usual "insert" mode, the characters typed on the keyboard are not inserted into the carriage position, but replace the characters after the carriage (by default, this mode is automatically enabled when you press the Insert key on keyboard when the rich edit element has input focus);
OnRE_InsOvrMode_Change - this event occurs when changing the mode from "Insert - Insert" to "Replace - Overwrite" and vice versa;
RE_DisableOverwriteChange - allows you to prohibit changing the above indicated mode (however, the OnRE_InsOvrMode_Change event still continues to fire on pressing the Insert key, if assigned);
RE_LoadFromStream(strm, i, fmt, selonly) - loads text in fmt format of length i characters from the strm stream, replacing the entire text or selection, depending on the selonly parameter;
RE_SaveToStream(strm, fmt, selonly) - saves all text or only the selection in the specified data stream;
RE_LoadFromFile(s, fmt, selonly) - loads text from a file (the whole file is loaded, so there is no length parameter, as opposed to the RE_LoadFromStream method);
RE_SaveToFile(s, fmt, selonly) - saves the text (all or only the selected portion of the text) from rich edit to a file;
OnProgress - this event fires regularly when saving or loading text from a rich edit window using the RE_LoadFromStream, RE_LoadFromFile, RE_SaveToFile and RE_SaveToStream methods;
RE_Text[fmt, selonly]- allows you to access the entire text or only the selected part of the text in a rich edit control as one line. The fmt parameter specifies how to receive a string when reading, and when writing, tells how to interpret the assigned string (plain text without formatting, text with formatting, and other types - see the description in the code or automatic help for a list of all different types of representation ). If this method does not work, during debugging, you can use the property
RE_Error - contains the error code (returned by the OnProgress handler);
RE_Append(s, CanUndo) - adds the string s to the end of the text, allows, if the value CanUndo = true, add this change to the rollback stack, which allows you to later undo this change;
RE_InsertRTF(s)- inserts string s, assuming it is the internal representation of rtf-formatted text. This method can be useful for quick insertion of pre-prepared formatted fragments of text (for example, when generating rtf documents programmatically);
RE_HideSelection(b) - allows to hide or show selection in rich edit control;
RE_SearchText(s, case, word, fwd, i1, i2) - performs a search for the text specified by string s in the region from position i1 to i2 (must be rearranged to search "back"), using additional search parameters: case - take into account the case of letters when comparing; word - search only whole words; fwd - search forward. Note: already in the Windows XP operating system, the rich edit library version 5.0 is used by default, for which this method does not work if the project is compiled without the UNICODE_CTRLS option. In this case, you should use the RE_WSearchText method, which transfers the string in Unicode;
RE_WSearchText(s, case, word, fwd, i1, i2) - similar to the previous method, but accepts a Unicode string (cannot be used for this reason in Windows9x);
RE_AutoURLDetect - this property determines the need for automatic recognition of Internet addresses and e-mail addresses in the text;
RE_URL - the last URL "visited" by the mouse cursor. Can be parsed by the OnRE_OverURL and OnRE_URLClick event handlers;
OnRE_OverURL - an event that is triggered when the mouse cursor is over an automatically determined URL, i.e. the address of the WEB-page on the Internet, or above the email address. To get the URL itself, an event handler can read the RE_URL property;
OnRE_URLClick - an event that occurs when the mouse button is clicked while the mouse cursor is over a URL. The handler can also read the RE_URL value to get the clicked address;
RE_NoOLEDragDrop - this method prohibits the use of the built-in rich edit (and always available without calling this method) ability to use drag-n-drop to drag text fragments between windows (including between windows of different applications);
RE_BottomLess - this "end-to-end" method sets the style to "bottomless" for the control, which allows it to scroll down outside the text boundlessly;
RE_Transparent - this property allows you to make rich edit partially "transparent" (performance is not guaranteed for all cases!);
RE_Redo - allows you to return a "rollback" of a number of recent operations. Unlike the usual control for editing unformatted text, rich edit remembers all the operations performed on the stack, and allows you to roll them back using the Undo method (and not just the last operation), and it is also possible for it to perform rollbacks back.
Additionally, I note that the set of visual extensions contains a special extension KOLOLERE2 (by Alexander Shakhaylo), which provides the ability to work with rich edit interface extensions. In particular, it allows you to insert images, tables and other OLE-objects into the text of "rich" input fields.