Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

cRichEdit - Standard RichEdit control for AutoHotkey scripts


  • Please log in to reply
110 replies to this topic
TodWulff
  • Members
  • 142 posts
  • Last active: Sep 15 2013 04:16 PM
  • Joined: 29 Dec 2007
Ok, I have successfully integrated the control into my project - woo hoo!

With the code you offered up a couple of posts ago, along with some minor tweaks, I was able to get the autoscrolling functioning as desired - i.e. retaining the positioning and selection when autoscroll is deselected, and automagically autoscrolling when same is selected.

Right now I am using a checkbox control with which to implement this. I am struggling a bit with the math to determine if the vertical scroll button is located at the bottom of the scroll bar, in order to programmatically turn auto-scrolling on and off. That is a battle for another day, however, as the checkbox control is fine, and I may just leave it in there, instead of trying to get cute.

The next step is to take advantage of the feature set that the tool offers.

I have implemented the RE control as a console display, displaying received text from a serially connected device. The device can generate user output from the user application, but also provides firmware messages (i.e. when programming is complete, etc.).

I'd like to differentiate the user app generated dialogue from the firmware generated dialogue via the use of different colors inside of the console (the RE control). i.e.:

Resetting...

Going Interactive...
Welcome back to ARMbasic Kernel[7.09] Copyright 2007, Coridium Corp.

Ready...

Flashing ARMmite v2 on COM 3 ... 0.38K code 0.02K data programmed

Resetting...

Going Interactive...
Welcome back to ARMbasic Kernel[7.09] Copyright 2007, Coridium Corp.

Ready...
Executing...

Testing... 5
Testing... 4
Testing... 3
Testing... 2
Testing... 1
BOOM!!!!!!!!


Going Interactive...
Going Interactive...
... Finished in 5036 ms

Resetting...

Going Interactive...
Welcome back to ARMbasic Kernel[7.09] Copyright 2007, Coridium Corp.

Ready...



Historically, I have given the user the ability to clear the control's contents by simply clicking a clear button, in which case, it totally erases the control's contents by setting it to null.

What I am struggling with is the implementation of the colorization of the text.

In reading the RTF specs from various sources, it seems that the control will need to have some embedded (markup) header information, as well as some inline markup for tagging the text in order to be different colors.

Maybe I am over-thinking it.?.

Is this indeed the case, or can I simply blank out the control, and then add arbitrary text, with inline mark-up, in order to get the desired results - on the fly? Or would I be better served to have a template file with which to use to hold the active console content. And inside of this template file is where I would store the (required ?) rtf header/color tables/etc. and periodically update the control's contents by placing my received strings inside of the template file and then pushing the content to the RE control?

I prolly over complicated what I am struggling with, but hopefully someone will be able to ascertain what I am trying to accomplish and offer constructive feedback on how best to accomplish this.

Please review and advise. Thank you!

-t
When replying, please feel free to address me as Tod. My AHK.net site...

Ice_Tea
  • Members
  • 131 posts
  • Last active: Aug 25 2010 11:11 AM
  • Joined: 12 Jan 2008
Hey, it was a long time ago i read this thread, but i don't remember anyone mentioning this... Are you going to add support for pictures? In wordpad you are unable to see pictures in rtf documents but on microsoft word I'm able to see pictures i add to the rtf document...

Rhys
  • Members
  • 761 posts
  • Last active: Aug 09 2013 04:53 PM
  • Joined: 17 Apr 2007
Can the RichEdit control be made read only?

Q
  • Members
  • 24 posts
  • Last active: Nov 14 2008 10:51 PM
  • Joined: 24 Oct 2007
I'm using cRichEdit.ahk Version 0.09 beta.

When I do the following to get the text back from the control, it looses the last character, please help.....

editnote1:=cRichEdit(REdit1, "GETTEXT")

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004
TodWulff, 300W, Rhys, sorry for the lack of response. I should check Email for notifications once in a while... :oops: .

TodWulff, If you're still looking for methods of changing text colours on the fly then pls let me know.

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

Hey, it was a long time ago i read this thread, but i don't remember anyone mentioning this... Are you going to add support for pictures? In wordpad you are unable to see pictures in rtf documents but on microsoft word I'm able to see pictures i add to the rtf document...

At the moment I'm not planning on adding support for pictures but I would be happy to include and/or add support for code for additional features if anyone else would like to contribute code that provides additional functionality ;) .

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

Can the RichEdit control be made read only?

Yes. One method is to modify the style parameter when creating the control.
cGUI("Add", REdit1, 10, 40, 480, 450, "RichEdit20A", "", 0x54B371C4|0x800) ; 0x800 = ES_READONLY



corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

I'm using cRichEdit.ahk Version 0.09 beta.

When I do the following to get the text back from the control, it looses the last character, please help.....

editnote1:=cRichEdit(REdit1, "GETTEXT")

Thanks for reporting the bug :) . This will be fixed in the next release (hopefully later today). If you need something sooner then please update this section in the cRichEdit.ahk file:
/* 
*****************************************************************************************
GetText - get the text in the control

_action	= GetText
opt1 = (1 - unicode, 0 - ANSI) Default ANSI 
*****************************************************************************************
*/
  Else If _action = GetText
  { 
    VarSetCapacity(_tmp3, 20, 0)
    If (opt1)
      _tmp2 = 1200
    Else 
      _tmp2 = 1252
    VarSetCapacity(_tmp1, 8, 0)
    NumPut(0, _tmp1, 0)
    NumPut(_tmp2, _tmp1, 4)
    _tmpSize := DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0x45F, "UInt", &_tmp1, "UInt", "0") + 1
    If (_tmpSize) {
      NumPut(_tmpSize, _tmp3, 0, "Int")    
      NumPut(_tmp2, _tmp3, 8, "Int")    
      VarSetCapacity(_tmp4, _tmpSize, 0)
      DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0x45E, "UInt", &_tmp3, "UInt", &_tmp4)
      VarSetCapacity(_tmp4, -1)
    }
  Return _tmp4
  }


Q
  • Members
  • 24 posts
  • Last active: Nov 14 2008 10:51 PM
  • Joined: 24 Oct 2007
Thanks, and by the way I think it's a great control.

Q
  • Members
  • 24 posts
  • Last active: Nov 14 2008 10:51 PM
  • Joined: 24 Oct 2007
once I have added this REDIT to my window I seem to be having difficulty resizing it.

How can you resize or move it once added to the window without destroying and recreating the window?

flashkid
  • Members
  • 115 posts
  • Last active: Apr 12 2013 06:33 PM
  • Joined: 25 Aug 2007
Is it possible to Highlight special words?

Example:
Var = 20 Minutes
cRichEdit(REdit1, "Highlight", Var, Red)
MsgBox, Highlighted!
Sleep 10000
cRichEdit(REdit1, "HighlightRemove", Var)
MsgBox, Removed!
Sleep 5000
cRichEdit(REdit1, "Highlight", Var, Red)
Var2 = Another Highlight
cRichEdit(REdit1, "Highlight", Var2, Green)

So that its shown as:
It's [color=red]20 Minutes[/color] past 18 o'clock.
This Line is [color=green]Another Highlight[/color] in the text.


derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
how would i display images which are embedded from other RTF creating apps?

everytime i open the rtf, my text is shown, but the image is not available.

is this control specific behaviour or is this behaviour due to lack of rendering such as with GDI?

derRaphael

All scripts, unless otherwise noted, are hereby released under CC-BY

Rhys
  • Members
  • 761 posts
  • Last active: Aug 09 2013 04:53 PM
  • Joined: 17 Apr 2007
Just chiming in that inline image support would be a huge benefit to this control, though I have no idea how difficult it would be to implement...

derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
the idea was using this "image" feature with a script backend so that text can be collapsed by selecting according menu and the collapsed text is represented by a lil graphic, which reveals collapsed text upon click

but not having the possibility to show graphics at all, somehow makes the idea worthless...

(i want to use the richEd as a render engine for an advanced AHK based ahk editor with syntax highlighting - hiEdit is not an alternative, since it lacks support for several features such as proper highlighting for multiline comments, or counterpart control for all kind of brackets or quotationmarks etc)

All scripts, unless otherwise noted, are hereby released under CC-BY

  • Guests
  • Last active:
  • Joined: --
is there a new version?