AHK RichText Editor

Post your working scripts, libraries and tools
burque505
Posts: 499
Joined: 22 Jan 2017, 19:37

AHK RichText Editor

21 Apr 2018, 20:28

This is code by just me, DigiDon and jeeswg, with a few mods for a context menu and support on Win7 for pasting images and simple tables.

I've been admiring just me's Class_Richedit for some time now, so I decided to try to give a tiny bit of extra juice to the RichEdit Sample that comes with it.

Needed to grab a window message (0x204, WM_RButtonDown) because the RICHEDIT50W control didn't play well with GuiContextMenu.
Edit April 24, 2018: Archive includes updated RichEdit OleCallback.ahk reflecting just me's changes below, and updated script removing the code referenced in the strikethrough above.

Ctrl-Alt-M for an alternate way to bring up the context menu (for mouse haters). Ctrl-Escape to exit the app.

Old code:
AHK RichEdit.zip
(32.09 KiB) Downloaded 41 times

New code:

Thanks, DigiDon, for the heads-up about incorrect files.
May 3, 2018:
RTE 3.0.zip
(32.33 KiB) Downloaded 34 times


Regards,
burque505
Attachments
RE2.3b.gif
RE2.3b.gif (51.27 KiB) Viewed 837 times
Last edited by burque505 on 03 May 2018, 10:24, edited 2 times in total.
User avatar
Drugwash
Posts: 560
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: AHK RichText Editor

22 Apr 2018, 08:31

Would you be so kind to test MyDiary from my repository (see signature)? I've used RichEdit50W with it (when available) even in Win98SE and had no problems with context menu AFAICR. The sources are not updated for Unicode/x64 usage so you may wanna use the compiled exe (ANSI only, AHK 1.0).
I'm most interested in the ability to add/paste images to a RichEdit control, will check out your code. Thanks for posting it.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
burque505
Posts: 499
Joined: 22 Jan 2017, 19:37

Re: AHK RichText Editor

22 Apr 2018, 08:40

Greetings! I just downloaded the two versions of MyDiary from your repository. I have to leave at the moment but I'll test them when I get back.
I use Screen2Gif, it's free, and updated often.
Regards,
burque505
User avatar
Drugwash
Posts: 560
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: AHK RichText Editor

22 Apr 2018, 08:50

Thank you, please take your time, there's no hurry.

As for the GIF, I've checked and it's still in a weird format that my Total Commander plug-in (Imagine by Chun Sejin) can't render correctly so that application is of no use to me (more so when my system doesn't meet its requirements), I've even deleted that remark before your comment.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
just me
Posts: 5425
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: AHK RichText Editor

22 Apr 2018, 09:16

Digidon already noticed that the problems with the context menu are caused by the use of RichEditOleCallback. Seemingly, the control doesn't send/pass a WM_CONTEXTMENU message to its parent (the Gui) in this case. You can try to post the message from IREOleCB_GetContextMenu().
burque505
Posts: 499
Joined: 22 Jan 2017, 19:37

Re: AHK RichText Editor

22 Apr 2018, 11:48

@just me, thanks for that tip! (I still need to add drag & drop from instructions you've given elsewhere, but I haven't gotten to it yet.)
@Drugwash, sorry that one didn't work, try Licecap (got this tip from BoBo). It's not as easy to use, but I bet it's more lightweight.
I got the source code for your MyDiary program, but the #Includes are missing, so I can't start it up. I'll take a look in your script folder and see if I missed anything. The exe from 0.0.6.0, by the way, choked on the first run on my Win7 64-bit, but ran on the second go-around.
Regards,
burque505
User avatar
Drugwash
Posts: 560
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: AHK RichText Editor

23 Apr 2018, 03:37

Thank you, I had already tried a few capture applications some time ago, Licecap included, but they all create the same type of GIFs. Dunno what the problem may be but rendering is horrible, black areas all over the place. Ah, let's forget about that.

Did I upload MyDiary 0.0.6.0? Pff, forgot about that. I remember trying some fixes and updates in that series but not sure about its current status. However, it definitely isn't fit for x64 usage, and not even for running under Unicode AHK. It does run under AHK 1.1 ANSI though, just tested it.
Unfortunately, development stalled once the 98SE machine was stopped for checkup and repairs, which has not yet happened.

If you miss dependencies, please run MyDiary with source as command line parameter, it will deploy most sources in a new folder. The rest is in this package:
MyDiary0060_missing_sources.7z
(2.53 KiB) Downloaded 15 times


Choking happened due to the inability to load any Hunspell dictionary, a check missing in the code. At first start the exe deploys the Hunspell dictionaries but only if the respective folder doesn't exist, and then tries to add their names to a submenu, retrieving that submenu's handle. If you first ran the source script and the dic folder wasn't present, the script created the folder but had no files to put in it; then, when you ran the exe, it saw the folder but couldn't load any dictionary, then retrieving the submenu handle failed because that sub menu didn't exist. There was a message box stating the error but it was hidden under the splash screen; it probably didn't occur to you to drag it away (yes, it's draggable). :) Manually deploying the dictionary files in the dic subfolder should fix it.

You may try v0.0.5.4, it may be more stable. Without an x64 machine at hand I won't be able to check and fix the code. However, hopefully something in there will be of use to you and anybody else interested.
Last edited by Drugwash on 23 Apr 2018, 04:34, edited 1 time in total.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
just me
Posts: 5425
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: AHK RichText Editor

23 Apr 2018, 04:24

This might show the context menu:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
tidbit
Posts: 1083
Joined: 29 Sep 2013, 17:15
Location: USA

Re: AHK RichText Editor

23 Apr 2018, 13:03

Drugwash wrote:Thank you, I had already tried a few capture applications some time ago, Licecap included, but they all create the same type of GIFs. Dunno what the problem may be but rendering is horrible, black areas all over the place. Ah, let's forget about that.

the rendering issue is probably due to transparency. some programs have an option to only draw the different pixels between frames. so less pixels = smaller file size.
licecap can remove that feature by unchecking this:
Image

also, it's probably an issue with your image viewer for not handling the transparency correctly. Or maybe sometimes the program screws up, not sure.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
burque505
Posts: 499
Joined: 22 Jan 2017, 19:37

Re: AHK RichText Editor

23 Apr 2018, 14:39

Hi just me, thanks for that code. I'm assuming that replaces the relevant code in "RichEdit OleCallback.ahk".

I've been trying to call it from the Rich Text Editor script, but I'm not certain exactly where to place it or what parameters to pass to it. I'm not really getting anywhere with it. What I've tried is this:

Code: [Select all] [Download] GeSHi © Codebox Plus

IREOleCB_GetContextMenu(IREOleCB, "", RE2.HWND, "", "MakeMenu")

("MakeMenu" is a label, not a function.)
My thought was that I needed to replace parameters in

Code: [Select all] [Download] GeSHi © Codebox Plus

IREOleCB_GetContextMenu(IREOleCB, SelType, OleObj, CharRange, HMENU)

with ones from the script.

Any guidance greatly appreciated :D

Regards,
burque505
just me
Posts: 5425
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: AHK RichText Editor

24 Apr 2018, 02:24

Hi burque505,

yes, it's a replacment for the function in "RichEdit OleCallback.ahk". Doesn't it work for you?

You should not call any of the RichEditOleCallback functions directly from the script. They are callback functions reserved to be automatically called by the RichEdit control.

You might return a handle of an existing menu from IREOleCB_GetContextMenu(). But
IRichEditOleCallback::GetContextMenu wrote:lphmenu
The handle of a context menu to use. This parameter is ignored if an error is returned. A rich edit control destroys the menu when it is finished with it so the client should not.
So you have to recreate the whole menu and all submenus each time the function is called. As of my tests, it doesn't work reliably when using the AHK Menu commands.

BTW: OnMessage(0x204, "RightClick") ; WM_RIGHTBUTTONDOWN added - burque505 - context menus are usually shown after WM_RIGHTBUTTONUP.

Regards,
just me
User avatar
Drugwash
Posts: 560
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: AHK RichText Editor

24 Apr 2018, 07:14

tidbit wrote:the rendering issue is probably due to transparency. some programs have an option to only draw the different pixels between frames. so less pixels = smaller file size. […] also, it's probably an issue with your image viewer for not handling the transparency correctly. Or maybe sometimes the program screws up, not sure.
Thank you. In order to avoid further off-topic discussions I've created a GIF-dedicated topic here.
My apologies to burque505! :oops:

Almost on topic: I've updated the main MyDiary script locally with Ptr-related data types and fixed struct operations, in an attempt to make it x64-compatible. Not sure if everything's alright, will have to double-check it.
However there is a problem: due to ANSI/Unicode differences, the database is not correctly recognized. I'll have to work on that, maybe even try to implement a standard API-based encryption system instead of the current machine-code one that may not even work in x64. In that case some sort of conversion system would have to be created for existing databases.
Therefore nothing has been released yet.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
burque505
Posts: 499
Joined: 22 Jan 2017, 19:37

Re: AHK RichText Editor

24 Apr 2018, 10:43

To just me: Yes, it is working fine with that addition to RichEdit OleCallback! Thanks for the clarification.
Drugwash, I look forward to the updated MyDiary script.
Regards,
burque505
DigiDon
Posts: 172
Joined: 19 May 2014, 04:55
Contact:

Re: AHK RichText Editor

03 May 2018, 10:07

Thanks for having done this first step in consolidating the sample burque ;)

I've planned to do it for some time now but I wanted to add/tweak so many things that I didn't find the time yet.
The thing is I have worked on a much tweaked version for my "to-be-officially-released-since-ever" :roll: (but hopefully now very soon :D ) notetaking software (EverFastAccess) implementing the RicheEdit class.
But porting some of it back to the editor means readapting it from my software and it will take some time.

But then again thanks for the first step I might implement some changes to your version direclty then.

@just me well done for having solved this context menu problem. I will try it.

Some changes I've made that I consider implementing in the RichEdit Sample (as you can see there are some...):
  • Nicer buttons (but need icons)
  • Stay ontop button
  • Better text color functionnality
  • New Copy style/Paste style functionnality
  • Better lists functionnality
  • Better Search/Replace functionnality
  • Increase/Decrease indent functionnality (uncomplete)
  • Insert rtf table/excel table functionnality
  • Insert custom hyperlinks functionnality
  • Insert images functionnality
  • Insert images special for Win7 that convert it to BMP to display it directly
  • Insert file dialog that allows embedding/links/displayed or icon file
  • Insert link to files
  • Insert link to folders
and some other stuff...

Here is what my Everfastaccess editor looks like
Image
With some other screens
Image
Image
Image

So I plan to release it at some point but I need to find the time
Last edited by DigiDon on 03 May 2018, 10:18, edited 4 times in total.
EverFastAccess : Take Notes on anything the Fast way: Attach notes, Set reminders & Speed up research in 1 gesture - AHK topic
AHK Dynamic Obfuscator L - Protect your AHK code by Obfuscation - AHK topic
QuickModules for Outlook : Sort Outlook emails very quickly to multiple folders - AHK topic
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
DigiDon
Posts: 172
Joined: 19 May 2014, 04:55
Contact:

Re: AHK RichText Editor

03 May 2018, 10:10

Some remarks on your new "RTE 3.0.7z"

The sample cannot work right away:
-> It has .bak extension you need to remove
--> It includes the RichEdit callback using a wrong filename : RichEdit OleCallback - modded.ahk so there is an error

You might want to change that
Last edited by DigiDon on 30 May 2018, 13:07, edited 1 time in total.
EverFastAccess : Take Notes on anything the Fast way: Attach notes, Set reminders & Speed up research in 1 gesture - AHK topic
AHK Dynamic Obfuscator L - Protect your AHK code by Obfuscation - AHK topic
QuickModules for Outlook : Sort Outlook emails very quickly to multiple folders - AHK topic
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
burque505
Posts: 499
Joined: 22 Jan 2017, 19:37

Re: AHK RichText Editor

03 May 2018, 10:28

Hi DigiDon, I updated the OP. I didn't find the "RichEdit OleCallback - modded.ahk" in non-".bak" version of the script, and it appears to be working fine in "RTE 3.0.zip".
Thanks for the heads up.
Regards,
burque505
Edit: Your preview looks very nice indeed! Looking forward to a release.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 9 guests