|
|
Updated - May 23, 2004 This Page Viewed: times. Here's the next release, Version 2.0. I'll leave it in Beta until I hear from people that everything is working properly. Lots of new properties!. (Coming soon!) I need your Help! In an effort to finally build a proper Help file I am looking for code samples using the props and methods of the RTF2 control. I am also looking for a more finished Access RTF2 TooolBar then the one I included in the original sample RTF2 MDB's. Please Email your suggestions and I will add them to the Help file I have started compiling. Production Release RTF2 1.8 May 23, 2004 RichText ActiveX Version 1.8 Fixed Default Font and BackColor props. Added Selxx props for Bold, Italic, UnderLine, FontName, and FontSize. Added Plaintext property. Fixed Backspace bug from version 1.7 Here is the full installation package of the RTF2 Active control, version 1.8: RichTextActiveXonlyVersion1.8.zip RTF2 control is an ActiveX RTF solution written in VC++. The RTF2 control is a complete editing/printing solution for Access 97 or higher. Autosizing of the RTF2 control is supported for A2K or higher. This is a full automatic install package. This install package contains 3 required files for the control to function. The OCX itself, RTF2.OCX and the 2 VC runtime files, Mfc42.Dll and Msvcrt.Dll. AFAIK the two VC runtime files will already exist on all installs of Windows. Bug Fix for A2K and A97 sample MDB's. There was some corruption in the sample Form itself. I have imported everything into a fresh MDB and the Form's corruption seems to be fixed. Please let me know if you see any more problems with the A2K or A97 Sample MDB's. Here are some sample MDB's to demonstrate the control's functionality. A2KRTF2Sample.zip and A97RTF2Sample.zip You must install the RTF2 ActiveX control before opening either of these sample MDB's. If you have ActiveX registration problems and you end up reinserting the RTF2 ActiveX control onto the sample Forms/Reports make sure you rename the control to "RTFControl" in order for the sample autosizing code to work properly. Both sample MDB's contain a ToolBar named RTF2. Remember to import this ToolBar into any MDB containing the RTF2 ActiveX control. Please note that the Toolbars are no longer needed for RTF2 Versions 1.4 and higher as they have a built in context/editing Menu. Here is a sample MDB from Andre Minhorst from Germany. It demonstrates how to break up an RTF document into separate paragraphs. AndreRTF.zip
The RTF2 ActiveX control requires a minimum of Version 3 of the Rich Edit DLL found on Windows 2K or higher installs. The control will work with earlier versions but you will lose advanced functionality, such as full text justification. You can get Version 3 for earlier versions of windows automatically installed by downloading the Windows Installer program from Microsoft found here: Windows Installer 2.0 Redistributable for Windows 95, 98, and Me:
Bugs/Workarounds for the RTF2 control Click here for sample code to resize the control simulating CanGrow/Shrink Where is the Intellisense for the RTF2 control in the VB IDE? How do I access the RTF2 control's Change event? How do I set the Default Font for the control? Click here for Keyboard Shortcuts Click here for Bugs/Workarounds Workaround for the Enabled and Locked properties for the RTF2 Control Where is the Version information? Click here for the older non-ActiveX RTF solutions: How can I copy the contents of the RTF2 control to MS Word?
How do I access the RTF2 control's Change event? With the VB IDE window object click on the down array for the Object dropdown control. Scroll down and select the RTF2 control. The name appearing in the drop down list window will be whatever you named your control on the form. Now to the very right of this window is the Procedure drop down control. Again click on the down arrow and a list of the supported events will appear. Select the Change event. Code will be added automatically to your form's class module that you can then add to/modify to derive the desired functionality.
Where is the Intellisense for the RTF2 control Declare an object of type RTF2 in your Form's Load event. For this example we will use the name "rtf" for our object. Dim rtf As RTF2 In the Form's Load Event, assign our object to an instance of the RTF2 control. Here we assume we have an RTF2 control on our form named "RTFcontrol" Set rtf = Me.RTFcontrol.Object Now whenever you reference the rtf object Intellisense will be available.
Here is code to support resizing of multiple RTF2 control in the same Detail section. The example assumes two RTF2 controls named "RTFControl" and "RTFControl2". Private Sub Detail1_Format(Cancel As Integer, FormatCount As
Integer) ------------------------------------------------------------------------------------------------------------------------------------------
How to set the Default Font for the control From the RTF2 Control's Property sheet "Other" TAB select select either "Font" or "Custom" ------------------------------------------------------------------------------------------------------------------------------------------
Rich Edit Shortcut KeysRich edit controls support the following shortcut keys. Unfortunately Access will not allow a couple of them to work but the majority of these shortcuts do!
Why can't I use Access's Enabled and Locked properties for the RTF2 Control. I spent tens of hours on this issue before I finally across a reference to this issue on the FMS site. The FMS control does not support the native Access control Enabled or Locked properties. Instead Enabled and Locked properties are exposed by the ActiveX control directly. What does this mean to you. Well, assuming your RTF2 control is named "RTF2" then to set the Enabled or Locked properties you would use code like: Me.RTF2.Object.Enabled = False
Known Bugs: First character or action entered in a new record is discarded. This is due to a bug with the host Access ActiveX container. The FMS control has the same bug. Their solution is to set the DIRTY prop for the form in the Current event. A nasty Clipboard bug that I have coded a solution for but it still bugs me that I cannot figure it out!
An Emal from Jaffar B Almoosawi > Q2: I have a long memo (3 pages) and I would like to start printing it How can I copy the contents of the RTF control to Microsoft Word The simplest method is to highlight the desired text, Right Click to get the Context Menu to appear, select Copy from the menu. You now have the contents copied to the Clipboard. At this point you can open MS Word and then Paste the contents of the clipboard into your Word document. If you need to programmatically insert your RTF data into a MS Word document(s) here are two solutions: a) Have both Access and Word open. Open an Access form that contains an RTF2 control bound to your RTF data field. Using Automation with the open Word application, you could loop through the recordset, copy the contents of the RTF2 control to the Clipboard as outlined above, and finally paste the contents of the clipboard into the open Word document at the desired insertion points. b) This method does not require that you use Access at all as long as you can access the MDB from Word that contains the RTF data. We can programmatically copy the raw RTF string data to the Clipboard as RTF data. Here's some code that will work in Access or Word.
Please note that I have redone the Version release numbers. The first release was improperly labeled as 2.0 where it should have been 1.2 Version 1.8 Better than BETA<grin> Fixed Default Font and BackColor props. Added Selxx props for Bold, Italic, UnderLine, FontName, and FontSize. Added Plaintext property. Fixed Backspace bug from version 1.7 Version 1.7 BETA Added FindTextRTF, Enabled, Locked and TabIncrementalValue properties. Fixed bug with SelStart. Context Menu now responds properly to Locked property. Cleaned code! Version 1.5 Added SelColor and SelBackColor methods to allow for programmatic control of the currently selected Text colors. Starting to add help strings for class Props and Methods. Version 1.4 Second production release. Fixed several GUI bugs and added new features, notably the common Selxxx props as used by the standard MS RTF control.. Version 1.2 First production release. Fixed several GUI bugs and added new features. All exposed functionality is now available via a right click popup menu so the Access ToolBar is no longer required. Version Beta .4 First release.
The following list describes which versions of Rich Edit are included in which releases of Microsoft Windows®.
Please Note: This is my first attempt at building this Help File and it is by no means complete. I will be adding more comments and sample source code over the next few weeks. If you have any relevant material please EMail me with a subject title of RTF2 Help File. Finally, there are a couple of Props/methods towards the end of this listing that you will not find in your current version, 1.8 of the RTF2 control. They do exist in version 2.0 which will be release shortly. RTF2Lib Interface Definition General Information Library: RTF2Lib (RTF2 ActiveX Control module) File: C:\Program Files\Lebans Holdings 1999 Ltd\RTF2\RTF2.ocx GUID: FC71F908-8308-450D-97CE-08E36A4DFBBF Version: 1.0 Enumerations This section lists enumerations exposed by RTF2Lib. Public Enum enumRTFAlignment rtfLeft=1 ' Left rtfRight=2 ' Right rtfCenter=3 ' Center rtfJustify=4 ' Justify rtfWordJustify=5 ' WordJustify End Enum Public Enum rtfParagraphLineSpacingConstants LineSpacingSingle=0 ' LineSpacingSingle LineSpacingOneAndAHalf=1 ' LineSpacingOneAndAHalf LineSpacingDouble=2 ' LineSpacingDouble LineSpacingTwips=3 ' LineSpacingTwips LineSpacingTwipsAnyMinimum=4 ' LineSpacingTwipsAnyMinimum LineSpacingTwentiethLine=5 ' LineSpacingTwentiethLine End Enum Public Enum RTFParagraphNumbering rtfNone=0 ' None rtfBullet=1 ' Bullet rtfArabicNumbers=2 ' ArabicNumbers rtfLowerCaseLetters=3 ' LowerCaseLetters rtfUpperCaseLetters=4 ' UpperCaseLetters rtfLowerCaseRoman=5 ' LowerCaseRoman rtfUpperCaseRoman=6 ' UpperCaseRoman rtfCustomNumber=7 ' CustomNumber End Enum Interfaces This section lists the Classes exposed by RTF2Lib. For each class, the methods and events are listed. RTF2 Methods/Properties hWnd As Long Returns the Window Handle for the RTF2 control. This can be used to extend the functionality of the control by using the SendMessage API and the Messages supported by the control not currently implemented. See: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/RichEdit/RichEditControls.asp ParagraphLineSpacing As rtfParagraphLineSpacingConstants Returns/sets a value that controls the paragraph line spacing of the selected text in a RichTextBox control. Use the the supported Line Spacing Constants detailed above to set the current amount of Line Spacing for the Selected Text. SelAlignment As Variant Returns/sets a value that controls the alignment of the paragraphs in a RichTextBox control. Use the the supported Alignment Constants detailed above to set the current alignment for the Selected Text. ParagraphLineNumbering As RTFParagraphNumbering Returns/sets a value that controls the numbering of the paragraphs in a RichTextBox control. Use the the supported ParagraphNumbering Constants detailed above to set the current paragraph numbering for the Selected Text. ParagraphNumberingTAB As Long
SelFontSuperscript As Boolean Returns/sets a value that determines whether text in the RichTextBox control appears on the baseline (normal), or as a superscript above the baseline. SelFontSubscript As Boolean Returns/sets a value that determines whether text in the RichTextBox control appears on the baseline (normal), as a subscript below the baseline. SelLeftIndent As Long
SelLength As Long Returns/sets the number of characters selected. SelStart As Long Returns/sets the starting point of text selected; indicates the position of the insertion point if no text is selected. Const SelTextRTF Returns/sets the text (in .RTF format) in the current selection of a RichTextBox control. Const SelText Returns/sets the string containing the currently selected text; consists of a zero-length string if no characters are selected. MaxCharactersAllowed As Long Specify MAX total characters in the RTF2 control Enabled As Boolean Enable/Disable input to the RTF2 control Locked As Boolean Lock/Unlock input to the RTF2 control TabIncrementalValue As Long Set the incremental value for each TabStop in TWIPS(1440/INCH) Const SelFontName Returns/sets the font used to display the currently selected text or the character(s) immediately following the insertion point in the RichTextBox control. SelFontSize As Long Returns/sets a value that specifies the size of the font used to display text in a RichTextBox control. SelFontItalic As Boolean Returns/set the italic format of the currently selected text. SelFontUnderline As Boolean Returns/set the underline format of the currently selected text. SelFontBold As Boolean Returns/set the bold format of the currently selected text. Const PlainText Gets/sets the plain text for the control Function RTFheight() As Integer Returns the height of the control based on the current contents Sub Cut Sub Copy Sub Paste Sub Undo Sub PasteSpecial Sorry...not implemeted yet! Sub SelFont Calls the Font Dialog Window. Applies the selection to the currently selected text Sub SelFontBackColor Obsolete...Use SelBackColor method instead Sub SelFontForeColor Obsolete...Use SelColor method instead Sub SelColor(Optional ByVal varSelColor As Variant) Set the Font Color for the Selected Text Sub SelBackColor(ByVal varSelColor As Variant) Set the Font BackColor for the Selected Text
Function FindTextRTF(ByVal strFindThisText As String, ByVal blMatchEntireWord As Long) As Long
Function LoadRTFfile(ByVal RTFfilename As String) As Boolean
Events Public Event Change() Public Event KeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer)
New - Jan 15, 2003 A2KRichTextControl.zip is a non ActiveX RTF solution for Access 2K or higher. It creates an RTF control from the Common Controls DLL. This current Beta version only works with Forms. A solution for Reports is in development and should be ready shortly. Version Beta .7 First release.
OLDER "Display only - no editing" version BUG - There is a Win2K bug when you output an RTF control to a Metafile DC. The calculated bounding rectangle contains a non valid value for the width. I am researching a fix now. RichTextClipboard.zip is a database containing a class that allows for the display of RTF text within a standard Access Image control. No RTF ActiveX control is required. This release works with all versions of the Rich Edit Control, from Version 1 to 3. Note there are 2 major versions of the RichEd20.DLL. If you check the DLL version you will see it is either Version 2 or 3 of the RichEdit control. While Win98 installs Version 2 some applications can install Version 3. You can also download version 3 directly from Microsoft. RichText.zip is a database containing a class that allows for the display of RTF text within a standard Access Image control. No RTF ActiveX control is required. Requires Version 3 of the RichEd20.DLL. Has not been updated to allow for transparency. Version 2.7 Now defaults to supporting transparency for the outputted text. Version 2.0 First release.
|
|
|