Lebans Holdings 1999 Ltd.

 Home ] Up ] Feedback ] Contents ] Search ] What's New ] Files & Tips ] 

RichText
Home
Up
Select A Row
Magnify
LimitCharsMemo
RotateText
ImageClass
AutoSize TextBox
ZoomInOut
PaintProgram
FormatByCriteria
CmdButton
SetGetSB
Transparent
AnimatedGifPlayer
LoadJpegGif
ImageControlToClipBoard
CanGrow
LimitTextInput
AutoSizeFont
AnimateForm
AutoUpDown
MonthCalendar
AutoColumnWidth
RichText
SelectAlpha
FormDimensions
LoadSaveJpeg
TabColors
ToolTip
TextWidth-Height
MouseWheelOnOff
AlternateColorDetailSection
ConFormsCurControl
ConditionalFormatting
AutoSizeOLE
ChangeMDIBackGround
RecordNavigationButtons
HTMLEditor
CopyGetRTFfromClipboard
OpenForm
GradientFill

RETIRED! September 2009

I have officially retired from all things Access. Please do not send Email requesting support as I will not respond.

 

Keep all of your questions to the Newsgroups where everyone will benefit!

 

 

Updated - May 23, 2004                                            This Page Viewed:Hit Counter 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:

http://www.microsoft.com/downloads/details.aspx?FamilyID=cebbacd8-c094-4255-b702-de3bb768148f&DisplayLang=en

 

Bugs/Workarounds for the RTF2 control

Where is the Help File?

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)

' Height of the current RTF2 Control
Dim Height As Integer
' Max height to allow for multiple RTF2 controls
Dim MaxHeight As Integer

' Init MaxHeight
MaxHeight = 0

Height = Me.RTFcontrol.Object.RTFheight
If Height > 0 Then
If Height < 32000 Then
Me.RTFcontrol.Height = Height
'Me.Section(acDetail).Height = Me.RTFcontrol.Height + Me.RTFcontrol.Top
If MaxHeight > Me.RTFcontrol.Height + Me.RTFcontrol.Top Then MaxHeight = Me.RTFcontrol.Height + Me.RTFcontrol.Top
End If
End If


Height = Me.RTFControl2.Object.RTFheight
If Height > 0 Then
If Height < 32000 Then
Me.RTFControl2.Height = Height
'Me.Section(acDetail).Height = Me.RTFControl2.Height + Me.RTFControl2.Top
If MaxHeight > Me.RTFControl2.Height + Me.RTFControl2.Top Then MaxHeight = Me.RTFControl2.Height + Me.RTFControl2.Top
End If
End If

' Now set the Detail Section's Height to the Maximum calculated value.
Me.Section(acDetail).Height = MaxHeight
End Sub

------------------------------------------------------------------------------------------------------------------------------------------

 

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 Keys

Rich 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!

Keys

Operations

Comments

Shift+Backspace Generate a LRM/LRM on a bidi keyboard BiDi specific
Ctrl+Tab Tab  
Ctrl+Clear Select all  
Ctrl+Number Pad 5 Select all  
Ctrl+A Select all  
Ctrl+E Center alignment  
Ctrl+J Justify alignment  
Ctrl+R Right alignment  
Ctrl+L Left alignment  
Ctrl+C Copy  
Ctrl+V Paste  
Ctrl+X Cut  
Ctrl+Z Undo  
Ctrl+Y Redo  
Ctrl+'+' (Ctrl+Shift+'=') Superscript  
Ctrl+'=' Subscript  
Ctrl+1 Line spacing = 1 line.  
Ctrl+2 Line spacing = 2 lines.  
Ctrl+5 Line spacing = 1.5 lines.  
Ctrl+' (apostrophe) Accent acute After 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 tilde See Ctrl+' comments.
Ctrl+; (semicolon) Accent umlaut See Ctrl+' comments.
Ctrl+Shift+6 Accent caret (circumflex) See Ctrl+' comments.
Ctrl+, (comma) Accent cedilla See Ctrl+' comments.
Ctrl+Shift+' (apostrophe) Activate smart quotes  
Backspace If text is protected, beep and do not delete it. Otherwise, delete previous character.  
Ctrl+Backspace Delete previous word. This generates a VK_F16 code.  
F16 Same as Backspace.  
Ctrl+Insert Copy  
Shift+Insert Paste  
Insert Overwrite DBCS 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 Arrow Move cursor one word to the right. See Ctrl+Left Arrow comments.
Ctrl+Left Shift Left alignment In BiDi documents, this is for left-to-right reading order.
Ctrl+Right Shift Right alignment In BiDi documents, this is for right-to-left reading order.
Ctrl+Up Arrow Move to the line above.  
Ctrl+Down Arrow Move to the line below.  
Ctrl+Home Move to the beginning of the document.  
Ctrl+End Move to the end of the document.  
Ctrl+Page Up Move one page up. If in SystemEditMode and Single Line control, do nothing.
Ctrl+Page Down Move one page down. See Ctrl+Page Up comments.
Ctrl+Delete Delete the next word or selected characters.  
Shift+Delete Cut the selected characters.  
     
     
Esc Stop drag-drop. While doing a drag-drop of text.
Alt+Esc Change the active application.  
Alt+X Converts the Unicode hexadecimal value preceding the insertion point to the corresponding Unicode character.  
Alt+Shift+X Converts 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+F12 Hex to Unicode. In case Alt+X is already taken for another use.
Alt+Shift+Ctrl+F11 Selected 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.

 

 

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

 

Bugs/Workarounds

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
from the first page, so I set the Keep together=No in the Detail section of
the report, so that the first page doesn't come blank (the Detail section is
too long and it won't fit with the Report and Page Headers and Footers on
one page), How can I do this?
> A2: I was able to make a work around for my Q2:
>
> My Page size is A4, with .5" margin from the top and .25" from the bottom.
> After some trial and error, I realized that the maximun space that should
be alocated to the Detail to force it to print from page one, is 11550
twips, (Keep together=No).
> The maximum length that can accomodate:
> Report Header + Detail + Page Footer is 15600
> So, force Me.RTFcontrol.Height of the first page to be 11550,
> and the pages after that can have the normal calculated size.
>
> RTFcontrolHeightPage1 = 15600 - (Me.ReportHeader.Height +
Me.PageFooterSection.Height)
>
> If [Page] = 1 And Me.Section(acDetail).Height > RTFcontrolHeightPage1
Then
> Me.RTFcontrol.Height = RTFcontrolHeightPage1
> End If
>
> This way I can print from the first page and the rest will be printed on
pages two and Three.
> One problem I couldn't fix: the last line of the second page gets repeated
as the first line on page three. But since I will rarely type such a long
memo, I was happy with this result.
>

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.

Copy/GetRTFfromClipboard

 

 

Version Information

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.

 

 

Rich Edit version DLL
1.0 Riched32.dll
2.0 Riched20.dll
3.0 Riched20.dll
4.1 Msftedit.dll

The following list describes which versions of Rich Edit are included in which releases of Microsoft Windows®.

Windows XP SP1 Includes Rich Edit 4.1, Rich Edit 3.0, and a Rich Edit 1.0 emulator.
Windows XP Includes Rich Edit 3.0 with a Rich Edit 1.0 emulator.
Windows Me Includes Rich Edit 1.0 and 3.0.
Windows 2000 Includes Rich Edit 3.0 with a Rich Edit 1.0 emulator.
Windows NT 4.0 Includes Rich Edit 1.0 and 2.0.
Windows 98 Includes Rich Edit 1.0 and 2.0.
Windows 95 Includes only Rich Edit 1.0. However, Riched20.dll is compatible with Windows 95 and may be installed by an application that requires it.

 

RTF2 HelpFile

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)

 

 

 

 

 

 

 

 

Older NON ActiveX solutions:

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.

 

 


 
 

May 23, 2004 Product Update
 
 
Rich Text ActiveX control. Version 1.8

Click Here!

 

Mar 15, 2005 Product Update
 
MouseHook  Replaces the MouseWheel DLL subclassing solution. Turns On/Off the MouseWheel with one line of code. No DLL registration required. Now supports Logitech mice!

Click Here! 

 

 

 
Back ] Home ] Up ] Next ] 
Stephen Lebans Copyright 2009

Last Modified : 09/11/09 12:03 AM