Jump to content

Rich Edit UDFs: a programmer-friendly approach


c.haslam
 Share

Recommended Posts

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
Spoiler

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

 

Link to comment
Share on other sites

  • 1 month later...

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

  • 3 weeks later...

Version 0.5 uploaded: now 96 functions.

Thanks for sharing!

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

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

Link to comment
Share on other sites

  • 1 month later...

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 month later...

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..

Link to comment
Share on other sites

  • 1 month later...

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?

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

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ë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

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ë 맧ëñ§ë øƒ !ïƒë.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...