Version 0.09 Beta.
A zip file that contains the necessary files and demo scripts can be downloaded here: Download.

Recent changes:[*:1pa4kl8w]AutoHotkey v1.0.47 or greater required
[*:1pa4kl8w]added: WordWrap On/Off
[*:1pa4kl8w]modified: fixed a bug in cGUI.ahk for specifying a HWND for the control's parent
[*:1pa4kl8w]added: tab_example.ahk example file to show one method of adding the RichEdit control to a tab
[*:1pa4kl8w]added: GetLineNum - to retrieve the current line number, the total number of lines or the line number at a specific character index
[*:1pa4kl8w]fixed: bug with specifying a colour by name
[*:1pa4kl8w]added: Align (Left, Right, Center)
[*:1pa4kl8w]added: ReplaceSel - to insert or replace text at the current position
[*:1pa4kl8w]added: GetRTF - to retrieve RTF code for the current selection or contents of the RichEdit control
[*:1pa4kl8w]added: an option to cGUI to specify the HWND to the parent control (currently untested)
[*:1pa4kl8w]modified: removed dependency on Insert/Extract Integer functions (now uses NumPut, NumGet instead)
[*:1pa4kl8w]updated: demo scripts (simple, feature)
[*:1pa4kl8w]modified: method used for colour names, minor bug fixes/tweaks
[*:1pa4kl8w]modified: split the include files into cGUI.ahk and cRichEdit.ahk since cGUI.ahk might be used for other controls in the future.
[*:1pa4kl8w]renamed: cGUI_RICHEDIT function to c_RichEdit() instead (easier to remember and less to type)
[*:1pa4kl8w]modified: feature_demo.ahk to use a ListView to list/test commands instead of the buttons that were used previously. This method seems to allow more flexibility when adding/modifying/testing new options
[*:1pa4kl8w]added: FontName _action to specify a font to use by name
[*:1pa4kl8w]added: GetFontSize _action to get the font size of the current selection
[*:1pa4kl8w]added: SetFontSize _action to set the font size of the current selection
[*:1pa4kl8w]added: FontStyle _action to set/toggle Bold, Italic, UnderLine, Strikethrough for the current selection or current position (optional custom dwMask and dwEffects settings available also)
[*:1pa4kl8w]added: FontColor _action to change the colour of selected text or change the colour at the current location (RRGGBB value or by name - same names/values as Object Colors in the AutoHotkey documentation)
[*:1pa4kl8w]updated: BackColor _action to support colour names also
[*:1pa4kl8w]updated: feature_demo.ahk script to test some of the newer features that have been added
[*:1pa4kl8w]Added the following to the cGUI_RICHEDIT() function:[*:1pa4kl8w]EXGETSEL - retrieves the starting and ending character positions of the selection
[*:1pa4kl8w]EXSETSEL - set the current selection
[*:1pa4kl8w]GETSELTEXT - get the current text that is selected in the control
[*:1pa4kl8w]GETTEXTLENGTH - get the number of characters in the control
[*:1pa4kl8w]GETTEXT - get the text in the control
[*:1pa4kl8w]BackColor - change the background colour of the RichEdit control
[*:1pa4kl8w]SETSCROLLPOS - scroll to a specific position in the control
[*:1pa4kl8w]GETSCROLLPOS - get the current scroll position in the control
[*:1pa4kl8w]AutoURLDetect - automatic detection of URLs[*:1pa4kl8w]fixed hInstance usage [thanks PhiLho]
[*:1pa4kl8w]fixed: RICHEDIT was hard coded [thanks PhiLho]
[*:1pa4kl8w]added FreeDlls option (_action param) to cGUI() to free all dlls loaded by the cGUI() function
[*:1pa4kl8w]updated demo to load RichEdit v2.0
[*:1pa4kl8w]modifed global variables used
[*:1pa4kl8w]Added simple_demo.ahk and feature_demo.ahk scripts to the zip file available for download
[*:1pa4kl8w]modified demo scripts to load a RichEdit1.0 control instead if run under Win95[/list]**Note to Win95 users: Win95 can load a RichEdit 2.0 control but the file riched20.dll is not included in a standard install and would have to be downloaded and installed separately.
Here's the code for a sample script (simple_demo.ahk - screenshot). The code for feature_demo.ahk is available in the zip file.
; v0.06 beta - updated: June 24, 2007
; **** Download the sample .rtf file if necessary ****
If !(FileExist(A_ScriptDir . "\test1.rtf")) {
SplashTextOn, 300, 30, !, Downloading sample file. Please wait...
URLDownloadToFile http://www.autohotkey.net/~corr/test1.rtf, %A_ScriptDir%\test1.rtf
SplashTextOff
}
; **** RichEdit Demo ****
Gui Add, Button, gOpenScript, Open Script
Gui Add, Button, ym gHelloWorld, Hello World!!
Gui Add, Button, ym gtest1, test1.trf
Gui Show, +hide w500 h500, RichEdit demo
If A_OSVersion = WIN_95
cGUI("Add", REdit1, 10, 40, 480, 450, "RICHEDIT")
Else
cGUI("Add", REdit1, 10, 40, 480, 450, "RichEdit20A")
cRichEdit(REdit1, "FileOpen", (A_ScriptDir . "\test1.rtf"))
Gui Show
Return
test1:
cRichEdit(REdit1, "FileOpen", (A_ScriptDir . "\test1.rtf"))
Return
OpenScript:
cRichEdit(REdit1, "FileOpen", A_ScriptFullPath)
Return
HelloWorld:
cRichEdit(REdit1, "Text", "Hello World!!")
Return
GuiClose:
If (REdit1)
cRichEdit(REdit1, "Destroy")
Gui, %A_Gui%:Destroy
cGUI("FreeDlls", NULL)
ExitApp
Return
; comment the following #Include lines if you are using stdlib and have copied the required
; cGUI.ahk and cRichedit.ahk files to your stdlib directory
#Include cGUI.ahk
#Include cRichEdit.ahk
I'll be adding additional functionality to the cRichEdit() function with each release. If you'd like to help out then feel free to add to the function and post your changes so that I can update the code in the first post. More to come soon... Enjoy




