| **Navigation:**  [[templates.htm|Templates]] > Guide to all Templates > [[additional libraries and templates.htm|Additional Libraries and Templates]] > RTFControl Class >====== RTFControlClass ====== | [[undortf code template.htm|{{btn_prev_n.gif|Previous page}}]][[additional libraries and templates.htm|{{btn_home_n.gif|Return to chapter overview}}]][[statistics library.htm|{{btn_next_n.gif|Next page}}]] | | || Clarion's RTFControlClass and support templates are wrappers around Microsoft's Rich Edit Control DLL's. The presence of RichEdxx.DLL is required in the Windows/System directory. At press time, there are two versions of this DLL. ·**Riched32.dll, wrapper Dll for Richedit 1.0** ·**Riched20.dll, Rich Text Edit Control, v3.x** More information regarding these versions can be obtained from the Microsoft web site: Clarion's implementation of an RTF (Rich text format) control is a basic TEXT control, with an RTF attribute added. The rich text field can be saved to a field or to a separate text file. Other components of a rich text control include a Toolbar, Format Bar, and Ruler, and may be displayed (by default) or hidden at runtime. The minimum size of a target RTF field is 256 characters. This is needed in order to maintain the rich text header information. If the field contains a lot of formatting a larger field size will be needed. In prior versions of Clarion, the support for RTF controls required a special global template extension, a central RTF Control with limited options for modification, and a wide variety of code templates that were clumsy to implement. The latest version of RTF templates have been greatly simplified, but at the same time made more flexible and powerful in configuration. Let's look at them now, and identify the new methods that they support. **RTFTextControl template** This new RTFTextControl allows for easy integration of RTF support into all of your applications, with additional code and control template support through the **RTFToolbar**, **RTFStatusBar**, and the **RTFAction** Code Template. The normal design flow of the new RTF text control support is as follows: 1.Populate the RTFTextControl 2.Populate the RTFToolbar 3.Populate the StatusBar 4.Add the RTFAction Code template for additional RTFcontrol functions and event embed points if needed. {{rtfcontext.jpg|RTFContext.jpg}} The **Context Menu** interface (shown above) allows you to construct custom menu items to add to the existing popup menu used with the RTF control. You can select from a list of actions to attach to each menu item that you create. These actions include Execute Routine, Post Event to Control, Call a Procedure, or Run a Program Adding the RTFTextControl offers the following additional template support: **RTFToolbar** The RTFToolBar Control Template populates a group of support controls to use with the RTFTextControl control template. There are no template prompts for this control, but you can disable or hide controls that you do not want to provide to the user. You can also modify the icons and text used on each support control. {{rtftoolbar.jpg|RTFToolbar.jpg}} From left to right, top to bottom: The **New** button clears the contents of the RTF Control. **Method(s) invoked:** **    RTF.Reset()   !Call to RTF handler** **    RTFControlClass.FileName = ''** **    RTFControlClass.RefreshFileName** **    RTF.SetFocus() ** The **Open** button prompts you to load an external RTF file's contents into the RTF control **Method invoked:** **    RTFControlClass.Load()** The **Save **button allows you to save the existing RTF control's contents to an external file. **Method invoked:** **    RTFControlClass.Save()** The **Print** button prints the RTF control contents. **Method invoked:** **    RTFControlClass.PrintDocument(RTFControlClass.DocumentTitle)** The **Find** button (the binoculars) opens the //Find dialog// window, allowing you to search for text in the target RTF control. **Methods invoked:** **    RTFControlClass.FindDlg()** **    RTFControlClass.RTF.SetFocus()** **Find and Replace** opens the //Find and Replace// dialog window, allowing you to search and replace target text in the RTF control. **Methods invoked:** **    RTFControlClass.FindAndReplaceDlg()** **    RTFControlClass.RTF.SetFocus()** **Cut**, **Copy** and **Paste** Performs the standard Windows cut, copy and paste actions for selected text in the RTF control. **Method(s) invoked:** **    RTFControlClass.Props.Cut() !calls to the RTFProperty INTERFACE** **    RTFControlClass.Props.Copy()** **    RTFControlClass.Props.Paste()** **Undo** and **Redo** allows you to undo the sequence of actions performed on an RTF control, and to redo those actions if needed. **Method invoked:** **    RTFControlClass.Props.Undo() !calls to the RTFProperty INTERFACE** **    RTFControlClass.Props.Redo()** The **Tab Stops** button allows you to access the //Tabs dialog//. Set your tab stops in millimeters, inches, or twips. The default hotkey to move to the next tab stop is CTRL+TAB **Methods invoked:** **    RTFControlClass.TabDlg (RTFControlClass.Props.Unit())** **    RTFControlClass.RTF.SetFocus()** The **Paragraph Indents** button allows you to access the //Paragraph Indents// dialog. Set the First line, Left side and Right side of the paragraph in millimeters, inches, or twips. Methods invoked: **    RTFControlClass.IndentDlg()** **    RTFControlClass.RTF.SetFocus()** The **Alignment** buttons provide the standard alignment features (left, right, center, and full justification) for the selected text. The appropriate Alignment property is passed to the target methods. **Methods invoked:** **RTFControlClass.Props.Alignment (RTFControlClass.Alignment)** Full justification is currently only supported in Rich Edit versions greater than 3.0. The presence of RichEd3//x//.DLL is required in the Windows System directory. The **Bullets and Numbering**/**Bullet Styles** buttons add bullets or numbers and set the style with these buttons. Bullets and numbering can only be applied at the start of a paragraph. **Methods invoked:** **  RTFControlClass.Props.BulletStyle|** ** ( CHOOSE (NOT RTFControlClass.Bullets,|** **   PARA:Nothing, RTFControlClass.BulletStyle))** **  !If Bullet Style button is pressed** **  IF RTFControlClass.Bullets** **   RTFControlClass.Props.BulletStyle (RTFControlClass.BulletStyle)** **  END** Finally, the **Font and Colors** controls set all aspects of the active font and color to use in the RTF control. **RTFStatusBar** The **RTFStatusBar** Control Template populates a simulated status bar made up of panel and string controls that can be applied to any window. There are no template prompts for this control. The information contained in this template is shown below: {{rtfstatus.jpg|RTFStatus.jpg}} **RTFAction** The **RTFAction** code template incorporates special support features for a target TEXT control that is using the RTF attribute. Use this code template with visual controls that identify the action that will be performed (e.g., a Save button to perform a Save action). The following actions, and supported prompts, are documented as follows: The **Save** action writes the contents of the RTF control to a designated target. The drop list **Mode** specifies whether to write the contents in //RichText// or //PlainText// format. Your //default// can be either one of these formats, but if you haven't set the default mode in hand code, the default mode specified by the templates is //RichText// format. The **File Name** sets the Save destination. This must be a CSTRING variable that you have defined, and be large enough to accommodate the full file name and path. **RTFControl1.Save(LOC:Filename,TEXT:PlainText)** When switching to PlainText Mode, the **AllowFormatChange** method must return TRUE to allow the internal default interface to switch formats from RTF to PlainText. Use the method's embed point, and set the ReturnValue of the method to TRUE: **ReturnValue = TRUE** The **SaveAs** action is very similar to Save, but **SaveAs** will always present a Save dialog window to the user. **RTFControl1.SaveAs(TEXT:Default)** The **Load** action is used to load the contents of an external RTF filename to the target RTF control. The **File Name** sets the target to load. As in the Save action, this must be a CSTRING variable that you have defined. **RTFControl1.Load(LOC:Filename)** **FindandReplace** is used to launch a search and replace into a designated RTF control. The Find value is searched, and the value in the Replace by prompt replaces the Find value text. **RTFControl19.FindAndReplace(CLIP(LOC:FindValue),CLIP(LOC:ReplaceWith))** The **SelectedText** action is used to move the current selected text to an external file name designated in the  File Name prompt. **RTFControl1.SelectedText(LOC:Filename)** The **SetFocus** action is used to simply select an RTF control on a window. This could be useful in windows with multiple tab controls. A button could be used to "hot select" the RTF control. **RTFControl1.SetFocus()** The **Print** action is used to print the current contents of an RTF control. Enter a string or variable name to send the Windows Job Name to the Print Engine. Make sure to prepend an exclamation point to the variable name (Example - !MyPrintJobName) **RTFControl1.PrintRTF('CW Report')** The **Touch** action is used like Prop:Touched to generate an Accepted event on the RTF control. You can make the action variable by entering a valid expression in the Expression prompt. The default value is TRUE. **RTFControl1.Touch(CHOOSE(True,True,False)) !IF TRUE** **RTFControl1.Touch(CHOOSE(False,True,False)) !IF FALSE** And finally, the **Changed** action is used to trigger the other supporting controls (like the status bar and toolbar controls) that a change has occurred, and will prompt the user to save any changes if they have not saved it yet. A value of TRUE (1) will be sent to the variable designated in the Variable prompt. **LOC:RTFChanged = RTFControl1.Changed()** Because rich text can include hidden information, the Changed Action can return TRUE even if there are no visible changes, and no calls to Touch(TRUE) have been executed.