Jump to content
Sign in to follow this  
c.haslam

Rich Edit UDFs: a programmer-friendly approach

Recommended Posts

c.haslam

Attached are some 80 UDFs for Rich Edit. They have all been tested fairly extensively. The .zip file includes Notes.rtf. The included Example.au3 reads Notes.rtf.

Many of the functions are based on the ones Prog@ndy collected from the forums and the ones he wrote.

Suggestions for improvements are welcome. If I failed to credit an author of some code, please advise. Without you guys, I wouldn't have advanced as far as I have.

...chris

Version 0.1 attached

Version 0.3 attached

Version 0.4 attached

Version 0.5 attached - now 96 functions

Edited by c.haslam
  • Like 2

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Share this post


Link to post
Share on other sites
c.haslam

Version 0.3 has been uploaded. I think that the UDFs are ready for submission to Gary Frost, but they do need peer review.

Edited by c.haslam

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Share this post


Link to post
Share on other sites
Dampe

Crashes every time i try to load "Example.au3"


Share this post


Link to post
Share on other sites
c.haslam

I found the bug: I developed the code using 3.2.12 and switched to 3.3.0.0 right at the end. In __GCR_StreamFromFileCallback I had wchar rather than char. A late-night error?

I have uploaded version 0.4. Thanks for the heads-up.


Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Share this post


Link to post
Share on other sites
c.haslam

Version 0.5 uploaded: now 96 functions.


Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Share this post


Link to post
Share on other sites
TheSaint

Version 0.5 uploaded: now 96 functions.

Thanks for sharing!

When I get a chance, I'll check it out!


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
c.haslam

Does anyone know (or have a suggestion) as to how to disable/enable a RichEdit control?

I think I could "cheat": call _GuiCtrlRichEdit_SetReadOnly and call _GUICtrlRichEdit_SetCtrlBkColor($hRichEdit,0xC0C0C0) to set the background to grey. But the control would still be a tab stop.

Is there an elegant way?

...chris


Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Share this post


Link to post
Share on other sites
Yashied
ProgAndy

Does anyone know (or have a suggestion) as to how to disable/enable a RichEdit control?

I think I could "cheat": call _GuiCtrlRichEdit_SetReadOnly and call _GUICtrlRichEdit_SetCtrlBkColor($hRichEdit,0xC0C0C0) to set the background to grey. But the control would still be a tab stop.

Is there an elegant way?

...chris

I think, it should work with these two funcs :)

ControlEnable($h_RichEdit, "","")
ControlDisable($h_RichEdit,"","")

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
c.haslam

Thanks. It works, so no need to include functions for this in the UDF family.


Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Share this post


Link to post
Share on other sites
dantay9

I got an error when trying to run _GuiCtrlRichEdit_SetCharColor.au3. It says that consdebug is not a function.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites
Ascend4nt

Does this have Hyperlink support? I'm just curious, as I've recently written a function to pull out hyperlinks from RTF data. Through experimentation, and from what I've read (mainly glanced over), the format is generally {HYPERLINK "http://www.google.com" hyperlink_text}. Of course, there can be any number of other braces between the end of the actual hyperlink in quotes and the full text representing that link - which my function takes into account (brace-level). I'm still probably missing a few variations on the RTF format, and I only support the \u#### unicode characters currently, but its a start.

Also, if its of any use, I've written 2 RTF functions, one which strips Binary-embedded objects from RTF data (occuring typically as {\bin#### xxxxxxxxx}), and another which grabs RTF data from the clipboard using a relatively standard clipboard get method..

Then again, this is all based on a lower-level, and it appears from a brief glance that most of the code uses an abstraction layer..

Share this post


Link to post
Share on other sites
Cusem

Great UDF!

Is it possible to add a tooltip to the RichEdit control?

And would love to be able to set the text color (read in the comments these functions don't operate well in RE v0.5). Any updates on this?

Share this post


Link to post
Share on other sites
LAttilaD

Trying to start Example.au3, it says _GUICtrlRichEdit_StreamFromFile is an unknown function, despite the fact GuiRichEdit.au3 is included and is in the include folder of Autoit. What should I do?


Láng Attila D., LAttilaD.org

Share this post


Link to post
Share on other sites
Kip

I haven't took a close look at it yet, but how is this different than ProgAndy's UDF?

btw, the PauseRedraw and ResumeRedraw functions are mine, probably some others too.

Edited by Kip

Share this post


Link to post
Share on other sites
quake101

Thanks for this great UDF. Would you please add a function to add hyper links to text? I really like the auto URL function but I want to add links to text with out showing the url.

Share this post


Link to post
Share on other sites
zackrspv

It seems that in version .5 the support for text color (_GUICtrlRichEdit_Get/SetCharColor) has been removed. Is this going to be changed?

The following code should allow you to set color:

Had to do some research lol but there are a few options that are useable from other richedit releases that will work for this one too

;====================================================================================================
; Function Name: _GUICtrlRichEdit_SetFontColor
; Description:    Select the text color
; Parameters    : $hWnd         - Handle to the control
;                 $hColor       - Color value (BGR)
;                 $iSelect      - Color entire text or selection (default)
; Return values : True on success, otherwise False
; Author        : Yoan Roblet (Arcker)
; Rewritten     : grham
; Notes         :
;====================================================================================================
;
Func _GUICtrlRichEdit_SetFontColor($hWnd, $hColor, $iSelec = False)
    Local $tCharFormat = DllStructCreate($tagCHARFORMAT2)
    DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
    DllStructSetData($tCharFormat, 2, $CFM_COLOR)
    DllStructSetData($tCharFormat, 6, $hColor)
    Local $iSelec2 = $SCF_ALL
    If $iSelec Then $iSelec2 = $SCF_SELECTION
    Return _SendMessage($hWnd, $EM_SETCHARFORMAT, $iSelec, DllStructGetPtr($tCharFormat))
EndFunc   ;==>_GUICtrlRichEdit_SetFontColor

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
Share on other sites
zackrspv

Thanks for this great UDF. Would you please add a function to add hyper links to text? I really like the auto URL function but I want to add links to text with out showing the url.

I've been using this UDF in my primary project at the moment (full RTF based chat). I found it easier to enable the LINK messages; and then write custom code to insert RTF code with links enabled in them. So, basically, I took what the user entered as link and TITLE, and formatted a RTF data message, and appended the RTF to the actual RTF control.

You can lookup, from many places, how to embed a link in RTF, and get the proper formatting.

$msg = "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}" & _
            "{\colortbl ;\red128\green0\blue0;}{\colortbl ;\red0\green0\blue255;}" & _
            "{\*\generator Msftedit 5.41.21.2508;}\viewkind4\uc1\pard\qc\cf1\b\f0\fs20\b0\fs20 :  \b[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & _
            $USERHANDLE & ":\b0  \ul\b \cf0\cf2\b " & _
            '{\field{\*\fldinst{HYPERLINK "'&$USER_LINK_LOCATION'&"}}{\fldrslt{\pard\f0\fs20 ' & $USER_LINK_TITLE & "\ulnone\b0 }}}" & _
            "\ulnone\b0\cf0\cf1:  " & $USER_LINK_MESSAGE & "  \b\i\cf0\b0\i0\par" & _
            "}"

So, basically, i just collected the following information:

* Link Location (actual link)

* Link Title (what you want the link to appear as)

* Link Message (any extra information about the link)

The $USERHANDLE is a variable I created to be able to get a data message out to my clients that looks like:

TomHanks: [18:53:22] LINK GOES HERE: Link message goes here.

So it looks properly in the code.

Granted, you can change the above RTF to what you need, but that process is what worked for me. Now, my clients can enter any links they want directly (just by typing them in), or can click on the 'hyperlink' button, and enter a custom title/message for a link as well.

Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.