FILE: RICHED2.ZIP AUTHOR: Dave Berton (db@null.net) TYPE: freeware VERSION: Beta 2 DESCRIPTION: Rich Edit Control ---------------- Clarion Rich Edit Control The Clarion Rich Edit Control allows you to provide RTF capabilities to your Clarion applications quickly and easily. Simple template wrappers and ABC-compliant objects provide access to a tiny DLL written in C++ which makes all the necessary Windows API calls to create and customize the Rich Edit Common Control. Using the Rich Edit Control Template, you can drop a Rich Edit Control onto a window, assign it to a variable, and compile. The Rich Edit object will handle all communication with the DLL, allowing you to safely operate at a higher, abstracted level. Depending on the amount of interest in this control, I will expand on its functionality and depth. Most likely, I will just release all of the code (both Clarion and C++) into the public domain, but I haven't decided on that yet. This control is definitely not ready for prime time, but I will only continue improving it if enough people want it to be. Send all suggestions and ideas to: 102644.3557@compuserve.com or db@null.net Enjoy. Dave Berton New in Beta 2 - 8/3/98 TAB key now works as expected. Support for Ctrl-B, Ctrl-U and Ctrl-I while editing. Added alignment, bullets and indentation. Expanded templates to use new features. Beta 1 - 7/16/98 Fast and easy setting of simple Rich Edit properties, such as Bold, Italic, and Underline at runtime Load and save RTF files Fast creation of Rich Edit Controls at runtime Print the contents of the Rich Edit Control Stream in to and out of CSTRING variables One-level undo Known Limitations There is still a nag screen (which will be removed once beta is done). The Rich Edit control is 32-bit only. FIXED in beta 2 For some reason, Clarion is eating the TAB key (presumably because the ACCEPT loop traps it to switch focus between fields). Until I can figure out a safe way to trap the TAB key in the Rich Edit control, there is a method called ForceTab() which can be used to force a tab character into the control. See the examples for more on this. If you are viewing this README file in the hand coded example program, you will notice that the TAB key does not work. Try Ctrl-T instead. (Interesting note: if you create a Rich Edit control in an APPLICATION frame (as opposed to in a regular WINDOW), the tab key operates normally). There is very minimal error checking when streaming in to or out of the control. This may cause some unexpected GPFs (for example, if you are streaming in and out of a CSTRING(2000), and the user pastes 30K of text into the control, you may have problems during the StreamOut()). I plan on having methods to limit the amount of text in the control if there is enough interest. Printing support is still lame. Unless I get more time, I am going to need some help implementing decent printing support (including creating WMF files to integrate this thing with the Clarion print engine). Streaming into the rich edit control corrupts the CSTRING variable that is being streamed. Until a proper stream-in is written, I simply restore the CSTRING to its original state immediately after the stream. This should not be noticeable. You can call font selection directly in the DLL (RESelectFont), however it is a little flaky right now. Use the AskFont method in the cRichEdit CLASS for something more stable. The Rich Edit control always appears last in the control order in a window (PITA). What is required? At runtime, the support file sRE.DLL, the Rich Edit Control 32-bit DLL, is needed. This DLL was written in C++, and compiled with Microsoft Visual C++ 5.0. In addition, the following support DLLs are needed: RICHED32.DLL (ships with Win95) COMDLG32.DLL COMCTL32.DLL MSVCRT.DLL Many, if not all, of these files can be found on most installations of Win95 and WinNT since many programs require them. Files The following files are in this installation: README.RTF (this file) \LIB\sRE.LIB (Rich Edit Lib file) \LIBSRC\cRE.INC (Rich Edit CLASS) \LIBSRC\cRE.CLW (Rich Edit CLASS) \LIBSRC\sRE.INC (Rich Edit DLL include) \TEMPLATE\RE.TPL (Rich Edit template) \TEMPLATE\RE.TPW (Rich Edit template) \DEBUG\sRE.DLL (Rich Edit DLL - debug version) \RELEASE\sRE.DLL (Rich Edit DLL - release version) \EXAMPLES\REAPP.APP (Application Example 1- see Examples below) \EXAMPLES\REAPP2.APP (Application Example 2- see Examples below) \EXAMPLES\REHANDCODE.PRJ (Hand coded project Example - see Examples below) \EXAMPLES\ After unzipping these files, place the LIB, LIBSRC and TEMPLATE files into their correspnding directories beneath your C4 directory. Note on the Rich Edit Templates The templates are fairly limited right now. They work mainly with the ABC chain, although you can use many of the CODE templates in the Clarion legacy chain. The templates generate a minimal amount of code (mostly one-line calls to object methods), so its almost just as easy to hand code it all (see REAPP2.APP for a fully handcoded example using AppGen). Of course, if someone has any ideas for expanding the temaplates, please let me know. I have only tested the control with hand-coded projects and the ABC templates. Note on the Rich Edit CLASS The Rich Edit CLASS is also fairly limited now, there is a lot of room for growth. All the documentation for the methods is contained in cRE.CLW. Examples The Hand Coded Project Example - REHANDCODE.PRJ: Load REHANDCODE.PRJ into Clarion. The main file for this project is REHANDCODE.CLW. Before compiling, make sure that there is a proper path to SRE.LIB in the 'Library, Object and Resource Files' (this is the Clarion LIB for sRE.DLL. It is found in the \LIB\ subdirectory in this install). No other files are required to make this program run (other that sRE.DLL itself). This example illustrates getting the Rich Edit control working completely by hand. However, the cRichEdit class makes life a lot easier (especially programming in AppGen - see the REAPP2 example). AppGen Example 1 - REAPP.APP: For this APP to load, you need to have the object files in your LIBSRC directory and the template files in your TEMPLATE directory. Make sure to register RE.TPL before loading the app. This example uses most of the templates to create a Rich Edit control as a hot field on a browse. It is also used in an update form. To create a Rich Edit control using the templates provided: 1. In the window formatter, select populate control template and select 'RichEditControl'. 2. Place the control on the window. You will be prompted for the USE variable - select a CSTRING variable which the Rich Edit control will use to (optionally) retrieve and (optionally) save its rich text. 3. After placing the control on the window, go to the 'Actions' tab. Here you have the option of naming the cRichEdit CLASS which will operate the Rich Edit control. You also have the option of streaming the contents of the USE variable into the control right after it is created at runtime. That is all you need to do. In the REAPP.APP example, you only need one more step to make this Rich Edit control a hot field. In the BrowseNotes procedure there is a single browse on the 'Notes' file. In the Browser Method Executable Code Section -> TakeNewSelection I have placed a CODE template which does a StreamIn() to the Rich Edit control (PRIORITY LAST). So, every time a new record is selected in the browse, the cRichEdit object streams the contents into the Rich Edit control. AppGen Example 2 - REAPP2.APP: This is an example of creating a Rich Edit control completely in embed code within AppGen (no templates). It is all pretty self explanatory, and it will give you a good feel for how the cRichEdit CLASS is used. There is one global embed and a few embeds in the ChildWin procedure.