Class RichEdit - update on 2015-04-14 (v0.1.05.00)

Post your working scripts, libraries and tools for AHK v1.1 and older
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Class RichEdit - update on 2015-04-14 (v0.1.05.00)

17 Nov 2013, 03:40

!!! This scripts won't run properly with AHK ANSI !!!
Change History:
Edit on 2014-05-20:
  • Another sample tweaked by DigiDon can be found here.
Note: All AHK scripts must be stored as UTF-8 with BOM! Also, you must set up a default printer! (THX, tmplinshi)

Well, that's my second attempt to make RichEdit controls available for AHK. This time it's based on the RICHEDIT50W control provided by Msftedit.dll. It does support some more features, but it is a Unicode control. I don't know whether it would work with AHK ANSI and actually didn't try. That's why AHK Unicode is required.

The project is built up of four files, three schripts and a RTF sample file:
  1. Class_RichEdit.ahk - the class definition.
  2. Class_RichEditDlgs.ahk - some common dialogs used in the sample script. It's not actually needed, but might make things a bit easier.
  3. RichEdit_sample.ahk - a "how to use" sample script.
  4. Test.rtf - a formatted RTF sample file.
Compared to my first attempt I've added some more formatting features like paragraph numbering, paragraph indentation, justified alignment, and so on, which are visible supported by the now used preregistered class. Also, I revised the "WYSIWYG" (wrap as printed) and printing code. It seems to give more precise results now. The sample script is a quick transcription of the former one. It won't win a price on a AHK programmers contest. Maybe someone is interested to spend a nice Toolbar to demonstrate more up-to-date programming techniques; it would be highly appreciated.

If I'll ever find time and power to write some kind of documentation, I'll do it. It's a rather hard job for me, because English, as you might have noticed, is not my native tongue. Until then I ask you for looking at the sample script and the marginal inline documentation.

Enough said, pictures speak louder than words:
RichEdit.png
Class_RichEdit.ahk v0.1.05.00:
I proudly present my first attempt to set up a GitHub repository to manage one of my scripts, so you'll find all the needed parts at GitHub. ;)

:arrow: Look at the sources on GitHub.
:arrow: Dowload from GitHub.
Last edited by just me on 14 Apr 2015, 00:36, edited 11 times in total.
arcticir
Posts: 693
Joined: 17 Nov 2013, 11:32

Re: Class RichEdit - rich edit control for AHK (Unicode)

17 Nov 2013, 11:36

This is very useful. Thanks.
User avatar
Learning one
Posts: 173
Joined: 04 Oct 2013, 13:59
Location: Croatia
Contact:

Re: Class RichEdit - rich edit control for AHK (Unicode)

18 Nov 2013, 05:42

Great job just me! Thanks for sharing! ;)
Johnny R
Posts: 348
Joined: 03 Oct 2013, 02:07

Re: Class RichEdit - rich edit control for AHK (Unicode)

19 Nov 2013, 02:12

Is it possible to transfer the script to AHK (ANSI)?
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class RichEdit - rich edit control for AHK (Unicode)

19 Nov 2013, 05:20

... but it is a Unicode control. I don't know whether it would work with AHK ANSI and actually didn't try. ...
It might work with AHK 1.1 (ANSI) after some modifications, but I'm not interested in trying it. The most important advantage of AHK (ANSI) was/is that it is providing more backward compatibility with AHK 1.0. AHK v2, which I'm impatiently waiting for, won't support ANSI any more. So it's time to switch to AHK (Unicode). If you have some scripts or functions causing problems with the Unicode version you cannot solve on your own, just ask for help. I'm sure you'll get all the help you need in this forum, as far it isn't about Bots.
Last edited by just me on 20 Nov 2013, 01:36, edited 1 time in total.
Johnny R
Posts: 348
Joined: 03 Oct 2013, 02:07

Re: Class RichEdit - rich edit control for AHK (Unicode)

19 Nov 2013, 12:44

I'm not interested in trying it
I'm not interested in your interests. I'm interested in help. Thank you.
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class RichEdit - rich edit control for AHK (Unicode)

20 Nov 2013, 01:38

If you have some scripts or functions causing problems with the Unicode version you cannot solve on your own, just ask for help. I'm sure you'll get all the help you need in this forum, as far it isn't about Bots.
Johnny R
Posts: 348
Joined: 03 Oct 2013, 02:07

Re: Class RichEdit - rich edit control for AHK (Unicode)

23 Nov 2013, 14:11

Using AHK (ANSI), I have problems in opening and saving files, look here:
Image
Image
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class RichEdit - rich edit control for AHK (Unicode)

24 Nov 2013, 00:49

... So it's time to switch to AHK (Unicode). ...
You didn't, so the problems are not related to the Unicode version (of AHK). This might be solved by adding , "UTF-16" to all StrPut/StrGet() statements in FileDlg() contained in Class_RichEditDlgs.ahk. But it would be 'a drop in the bucket' / 'ein Tropfen auf den heißen Stein'.
Johnny R
Posts: 348
Joined: 03 Oct 2013, 02:07

Re: Class RichEdit - rich edit control for AHK (Unicode)

24 Nov 2013, 05:16

This might be solved by adding , "UTF-16" to all StrPut/StrGet() statements in FileDlg() contained in Class_RichEditDlgs.ahk.
Open/Save is now OK. Thank You! Now I have a problem with "Find". The Script does not find Strings in the rtf-file...

Image
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class RichEdit - rich edit control for AHK (Unicode)

25 Nov 2013, 01:10

... The Script does not find Strings in the rtf-file...
Yes, of course. You'll find the reason in Class_RichEditDlgs.ahk again, this time in FindText() and FindTextProc(). There are only two statements dealing with strings in this methods:
  • FindText() -> Buf := Text
  • FindTextProc() -> Find := StrGet(NumGet(L + Offset, 0, "UPtr"))
Both Buf and Find must contain Unicode ("UTF-16") strings. Maybe it will solve the problem.

BTW:
ANSI3.png
*All good things come in threes.*
Johnny R
Posts: 348
Joined: 03 Oct 2013, 02:07

Re: Class RichEdit - rich edit control for AHK (Unicode)

25 Nov 2013, 12:49

I resign. It's too difficult for me...
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Class RichEdit - rich edit control for AHK (Unicode)

26 Nov 2013, 07:32

Maybe I'll try.
Recommends AHK Studio
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Class RichEdit - rich edit control for AHK (Unicode)

26 Nov 2013, 12:55

fu:
Error in #Include file ClassRichEdit.ahk
This DllCall requires a prior VarSetCapacity specifically:
269: Return DllCall("Comctl32.dll\DefSubclassProc", "Ptr", This, "UInt", M, "Ptr", W, "Ptr", L)
But works in AHK Unicode
Recommends AHK Studio
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class RichEdit - rich edit control for AHK (Unicode)

27 Nov 2013, 00:26

I cannot reproduce this error (AHK 1.1.13.01 (ANSI) - Win 7 Prof. x64)
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Class RichEdit - rich edit control for AHK (Unicode)

27 Nov 2013, 02:34

Newest Version Ansi x86 XP Prof SP3
Recommends AHK Studio
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class RichEdit - rich edit control for AHK (Unicode)

28 Nov 2013, 00:49

Well, what are you trying to do before you get this error?
User avatar
oldbrother
Posts: 273
Joined: 23 Oct 2013, 05:08

Re: Class RichEdit - rich edit control for AHK (Unicode)

29 Nov 2013, 00:21

"Choose Font" is not working. My system: XP PRO SP3
1.jpg
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class RichEdit - rich edit control for AHK (Unicode)

29 Nov 2013, 05:29

oldbrother,

thanks for reporting. This will be fixed tomorrow.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 122 guests