AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

cRichEdit - Standard RichEdit control for AutoHotkey scripts
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
casano



Joined: 14 Nov 2007
Posts: 6
Location: Germany

PostPosted: Fri Nov 16, 2007 7:53 am    Post subject: Reply with quote

Thanks for that great piece of software! For my special purpose I need word wrap (as others did). Here is a quick & dirty solution:

In cGUI.ahk immediately after

If (ErrorLevel != 0 OR _ctrlID = 0)
Return "ERROR: Error creating control" . ErrorLevel . "/" . A_LastError

add

DllCall("SendMessage", "UInt", _ctrlID, "UInt", 0x448, "UInt", "0", "UInt", "0") ; EM_SETTARGETDEVICE

This works for me, but corrupt will know better, how to do it the clean way.
Back to top
View user's profile Send private message
ezuk



Joined: 04 Jun 2005
Posts: 146

PostPosted: Thu Dec 06, 2007 4:51 pm    Post subject: Scroll bars? Reply with quote

Nice control!

How do I make the scroll bars disappear? I can't even make them disappear when there's nothing to scroll. I want them to disappear completely, even if there's something to scroll. (And I don't want multi-line...)
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2485

PostPosted: Sun Dec 09, 2007 6:24 pm    Post subject: Reply with quote

Thanks for the code suggestion casano Very Happy . I'll have a look.

ezuk, the scrollbars are part of the default style used to create the control. Same with multi-line. I'll look into adding a function to change a few style options to make things a bit more user friendly Smile . Thanks
Back to top
View user's profile Send private message Visit poster's website
Fuco



Joined: 21 Mar 2006
Posts: 49
Location: Slovakia, Europe :)

PostPosted: Tue Dec 18, 2007 5:13 pm    Post subject: Reply with quote

how can i make it read only ? and also is there a function that will jump to the end of doc (+new line) ? so i can just append stuff at the end ( imagine something like IRC log or whatever... )

maybe add function addline() to append text to the end of doc.

btw thanx for this Razz

EDIT: Ok i know how to make it readonly, just add 0x800 style and its ok Razz so now i need jump to the end function Razz
_________________
RegExReplace("C:\Program Files\AutoHotkey", "(^C)(?=\W).{4}((?i)[GOD])\w{1,4}\s(\D)(?:\w+)*\\(?3)(u|o).*?(k).*" , "$3$4$l1$5$2")
Back to top
View user's profile Send private message
veio
Guest





PostPosted: Tue Jan 29, 2008 1:31 pm    Post subject: Reply with quote

hello,
nice object, but to add the richedit to another gui window does not work.
Code:
Gui, 3:Show, +hide  H550 W550,HH Converter

If A_OSVersion = WIN_95
  cGUI("3:Add", REdit1, 10, 40, 480, 450, "RICHEDIT")
Else
  cGUI("3:Add", REdit1, 10, 40, 480, 450, "RichEdit20A")
cRichEdit(REdit1, "FileOpen", (A_ScriptDir . "\test.rtf"))

Gui, 3:Show

This adds the richedit to the main gui window. What am i doing wrong?

veio
Back to top
veio
Guest





PostPosted: Tue Feb 05, 2008 3:19 pm    Post subject: Reply with quote

maybe i found the error:
in cGUI.ahk at "if(_Action0="3")" it must be "else if" i guess.
Back to top
JDP
Guest





PostPosted: Sun Mar 02, 2008 1:46 pm    Post subject: RTF within a TAB2 Reply with quote

Whe doesn't this work?
Code:

;TRY TO PUT RTF UNDER A TAB
Gui,add,Tab2,,one|two
Gui,Tab,two
GuiHwnd := WinExist()
cGUI("1:Add:%GuiHwnd%", REdit1, GMarginW, GRTFeditT, GRTFeditW, GRTFeditH, RTFeditor)


Note:
Code:

If A_OSVersion = WIN_95
  RTFeditor:="RICHEDIT"
Else
  RTFeditor:="RichEdit20A"
Back to top
corrupt



Joined: 29 Dec 2004
Posts: 2485

PostPosted: Sat Mar 08, 2008 6:13 am    Post subject: Reply with quote

I'm pretty sure you need to specify the HWND of the TAB. I'll see if I can put an example together... Smile
Back to top
View user's profile Send private message Visit poster's website
corrupt



Joined: 29 Dec 2004
Posts: 2485

PostPosted: Sat Mar 15, 2008 11:35 pm    Post subject: Reply with quote

Updated to version 0.08 beta Smile

- fixed a bug in cGUI that prevented specifying a HWND for the control's parent
- added an example script for adding the control to an AutoHotkey Tab control to the download (link on the first page).



Here's one method for adding the RichEdit control to a Tab (version 0.08 or higher required):
Code:
Gui, Add, Tab, x10 y10 w380 h380 +0x2C2, Tab1|Tab2|Tab3
Gui, Add, Button, w100 h30,This is a test
Gui, Add, Text,, Please go to tab 2 to see the RichEdit control
Gui, Tab, Tab2
Gui, Add, Button, w100 h30,Ok
Gui, Add, Picture, w320 h270 HwndREparent1

Gui, Add, Text,, This is another test control
Gui, Tab, Tab3
Gui, Add, Button, w100 h30,Cancel

If A_OSVersion = WIN_95
  cGUI("1:Add:" . REparent1, REdit1, 0, 0, 320, 270, "RICHEDIT")
Else
  cGUI("1:Add:" . REparent1, REdit1, 0, 0, 320, 270, "RichEdit20A")

cRichEdit(REdit1, "ReplaceSel",
(
"{\rtf1\ansi\ansicpg13312\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fswiss\fprq2\fcharset0 Arial Black;}}{\colortbl ;\red0\green0\blue0;\red128\green128\blue128;\red255\green0\blue0;\red0\green0\blue255;\red0\green255\blue0;\red255\green0\blue255;}\viewkind4\uc1\pard\nowidctlpar\cf1\f0\fs20 .\cf2\f1 This is a test\cf3\f0\par\cf4\parTesting 1 2 3 4\par\par\cf5\fs56 Hello\cf4\fs20  \cf6\fs44 World\cf4\fs20   :) \par}
}"
))

Gui, Show, h400 w400, Tab Test
Return

GuiClose:
If (REdit1)
  cRichEdit(REdit1, "Destroy")
Gui, %A_Gui%:Destroy
cGUI("FreeDlls", NULL)
ExitApp
Return

; comment the following #Include lines if you are using stdlib and have copied the required
; cGUI.ahk and cRichedit.ahk files to your stdlib directory

#Include cGUI.ahk
#Include cRichEdit.ahk

Back to top
View user's profile Send private message Visit poster's website
TodWulff



Joined: 29 Dec 2007
Posts: 139

PostPosted: Sat Apr 19, 2008 10:47 pm    Post subject: Reply with quote

corrupt (or someone else Smile),

Can you please take a peek at my most recent request for assistance? I haven't gotten a response to it therein. Lexikos (via IRC) pointed me towards another thread, which has potential for being a means of resolution. While reading that, I came across this thread, which seems to be equally as exciting.

I attempted to and have successfully integrated the use of cRichEdit into my IDE project. It was actually pretty easy, once I got over the initial fear of breaking everything with changing one of the most important controls in my project.

Anyways, if you could offer input on how you might go about trying to address my needs, via the use of your tools, it would be greatly appreciated. TIA.

Take care.

-t
_________________
When replying, please feel free to address me as Tod. My AHK.net site...
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2485

PostPosted: Sun Apr 20, 2008 1:17 am    Post subject: Reply with quote

Hi TodWulff Smile . There are likely a few methods that you could use to scroll to the bottom of the control. One method might be to use GetTextLength to get the number of characters in the control then use EXSETSEL to set the current selection to the number of characters in the control (start and end position both set to the number of characters in the control). You can test this method by using the commands in the Feature_Demo script that is included in the download.

Another method might be to send a <ctrl> + <end> keystroke to the control... There are a few other methods also... Since the control that gets added using the code here is a standard Windows RichEdit control (not modified - this code is just a wrapper), you will likely find that many of the other methods/functions that you find for use with Edit/RichEdit controls will likely work with this instance of the RichEdit control also.
Back to top
View user's profile Send private message Visit poster's website
TodWulff



Joined: 29 Dec 2007
Posts: 139

PostPosted: Sun Apr 20, 2008 1:21 am    Post subject: Reply with quote

Thanks corrupt.

Maybe I confused the issue a bit. Yeah, the movement to the bottom of the control is not an issue.

What I am wondering how to accomplish is how do I keep the text in the displayed portion of the control static, while appending to the end of the text in the control...

Is this something that you think is do-able?

-t
_________________
When replying, please feel free to address me as Tod. My AHK.net site...
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2485

PostPosted: Sun Apr 20, 2008 5:26 am    Post subject: Reply with quote

Here's a subroutine that might not be exactly what you're looking for if you are adding to the control constantly at the end and trying to scroll and read through the results at the same time...

Code:
testadd:
  ; Get current scroll position and current selection/caret position
  curpos := cRichEdit(REdit1, "GETSCROLLPOS")
  cursel := cRichEdit(REdit1, "EXGETSEL")
  DllCall("LockWindowUpdate", "UInt", REdit1) ; stop refreshing the control
  ; move to the end of the control
  endpos := cRichEdit(REdit1, "GETTEXTLENGTH")
  cRichEdit(REdit1, "EXSETSEL", endpos, endpos)
  ; add text
  Loop, 200
    cRichEdit(REdit1, "ReplaceSel", "This is a test`r`n`r`ntesting 1 2 3 4 `r`n`r`na b c d ", true)
  ; set the scroll position and selection back to the previous values
  StringSplit, sxy, cursel, |
  cRichEdit(REdit1, "EXSETSEL", sxy1, sxy2)
  StringSplit, xy, curpos, |
  cRichEdit(REdit1, "SETSCROLLPOS", xy1, xy2) 
  DllCall("LockWindowUpdate", "UInt", 0) ; resume refreshing
  ControlFocus,, ahk_id %REdit1%
Return
Back to top
View user's profile Send private message Visit poster's website
corrupt



Joined: 29 Dec 2004
Posts: 2485

PostPosted: Sun Apr 20, 2008 5:33 am    Post subject: Reply with quote

Updated to version 0.9

- added WordWrap option - Thanks casano
Back to top
View user's profile Send private message Visit poster's website
TodWulff



Joined: 29 Dec 2007
Posts: 139

PostPosted: Sun Apr 20, 2008 5:51 am    Post subject: Reply with quote

Thanks corrupt - looks to be working with some minor tweaks.!.

I see in another post above where another user was able to set the control to read only with a style of 0x800. I've been struggling to implement this as I don't want the user to have the ability to alter the contents of the console window. Can you provide an example of the use of the 0x800 style in the cRichEdit Constructs?

Take care. Thanks again!

-t

BTW, does the WordWrap'g you just added, negate the need for, and subsequently suppress, the horizontal scroll bar, when enabled? If not, you might want to consider it...
_________________
When replying, please feel free to address me as Tod. My AHK.net site...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Page 5 of 8

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group