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
buster25
  • Members
  • 2 posts
  • Last active: Mar 25 2011 09:11 AM
  • Joined: 28 Oct 2008
Hello, sorry for my English, I'm from Spain.

This is the Find Text Function.

No Loop for single replacement.

; ******************************PLACE IN feature_demo.ahk********************
^R::
SearchText:="Hello" 
ReplaceText:="Morning" 
Lenght_String:= % StrLen(SearchText)
cRichEdit(REdit1, "FindText",SearchText,Lenght_String,ReplaceText)
Return
; ***************************************************************************



; *******************************PLACE IN cRichEdit.ahk***********************

Else If _action = FindText
  {   
  VarSetCapacity(FindText,12,0) 
  Loop
    {
    ;--------------------------------REDIT TEXT LENGHT---------------------    
    VarSetCapacity(_tmp1, 8, 0)
    NumPut(0, _tmp1, 0)
    NumPut(_tmp2, _tmp1, 4)
    Text_Lengt:= % DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0x45F, "UInt", &_tmp1, "UInt", "0")  
    ;--------------------------------------------------------------------------------
    NumPut(Result,FindText)  
    NumPut(Text_Lengt,FindText,4)  
    NumPut(&opt1,FindText,8) 
    Result:=DllCall("SendMessage","UInt",_ctrlID,"UInt",0x438,"UInt",0x5,"UInt",&FindText)
    
    If (Result=-1)
      Break
    ;---------------------------------SELECT RANGE TEXT----------------
    string_start:=Result
    string_end:=Result+opt2
    VarSetCapacity(_tmp1, 8, 0)
    NumPut(string_start, _tmp1, 0, "Int")
    NumPut(string_end, _tmp1, 4, "Int")
    DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0x437, "UInt", "0", "UInt", &_tmp1)
    
    
    
    ;------------------SEND NEW TEXT or COLOUR REPLACE or ... -------------------------
    _tmp2 := true
    DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0xC2, "UInt", _tmp2, "UInt", &opt3)       
    ;------------------------------------------------------------------------------
    Result:=1
    }  
Return
  }

;*****************************************************************************************


Use this for colour replacement.

color:="Red"
    
    _cnt1 := Instr(_predef, color . "|")
    If (_cnt1)
      color := SubStr(_predef, (_cnt1 - 7), 6)
    If (SubStr(opt3, 1, 2) = "0x")
      StringTrimLeft, color, color, 2
    color := "0x" . SubStr(color, 5, 2) . SubStr(color, 3, 2) . SubStr(color, 1, 2) 

    VarSetCapacity(_tmp1, 60, Chr(0))											; CHARFORMAT struct
    NumPut(60, _tmp1, 0, "Int")													; cbSize
    NumPut(0x40000000, _tmp1, 4)												; dwMask
    NumPut(color, _tmp1, 20)														; crTextColor

  ; ** apply the colour
    DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0x444, "UInt", "1", "UInt", &_tmp1)
    
    ;------------------------------------------------------------------------------
    Result:=Result+opt2


bekihito
  • Members
  • 42 posts
  • Last active: Sep 04 2013 07:33 PM
  • Joined: 03 Feb 2010
Add this to your cRichedit.ahk for scrollbar hiding
/* 
*****************************************************************************************


_action	= Show or hide scrollbar 
opt1= 1-vertical scrollbar 0- horizontal scrollbar
opt2=1-show 0-hide
EM_SHOWSCROLLBAR http://msdn.microsoft.com/en-us/library/windows/desktop/bb774298(v=vs.85).aspx
*****************************************************************************************
*/
  Else If _action = ShowScrollbar
  { 
	Return DllCall("ShowScrollBar", "uInt", _ctrlID, "Int", (opt1), "Int", (opt2)) 
  }

Usage in your code:
cRichEdit(REdit1, "ShowScrollbar","0","0") ;hides horizontal scrollbar


  • Guests
  • Last active:
  • Joined: --
Is there a way to automate the process of getting the 'colour/font codes' ?

Because writing it in exel and copying it, wont copy the formation.

And i didnt figure out how to use the (kind of) BBcode like system, yet.

Bugz000
  • Members
  • 155 posts
  • Last active: Oct 14 2015 01:03 PM
  • Joined: 24 Feb 2011
does anyone have the original zip file? having the .net user files all missing has completely destroyed the whole structure of the forum - may aswell delete the entire Scripts section and have them all repost :/

i managed to find "cRichEdit.ahk" through excessive googling but *sigh* .... -____- i shouldnt have to be asking this in the first place if people kept their heads screwed on...

n39peTm.jpg
Hire me to write your code! (join IRC or PM me for details)


erickosanchezj
  • Members
  • 1 posts
  • Last active: Jul 04 2013 07:52 PM
  • Joined: 02 Jul 2013

To everyone who lands here, check: http://www.autohotke...ated-5-22-2013/



El Capitan
  • Members
  • 28 posts
  • Last active: Jul 14 2015 01:08 AM
  • Joined: 30 Oct 2014

hi... sorry for bringing back an old post...

am trying to add a tabstops functionality to a crichedit.ahk but its just not working...

heres my code segment that i added...

 

  Else If _action = SetTabStops
  {
    Static MinT := 30                ; minimal tabstop in hundredth of inches
    Static MaxT := 830               ; maximal tabstop in hundredth of inches
    Static Align := {L: 0x00000000   ; left aligned (default)
                 , C: 0x01000000   ; centered
                 , R: 0x02000000   ; right aligned
                 , D: 0x03000000}  ; decimal tabstop
    Static MAX_TAB_STOPS := 32
 
    IC := GetMeasurement()
    TabStops :=  op1 ; {200: "L",300: "L"}
      Tabs  := []
      For Position, Alignment In TabStops {
         Position /= IC
         If (Position < MinT) Or (Position > MaxT)
         Or !Align.HasKey(Alignment) Or (A_Index > MAX_TAB_STOPS)
            Return False
         Tabs[A_Index] := (Align[Alignment] | Round((Position / 100) * 1440))
         TabCount := A_Index
        ; msgbox % IC "`n" position "`n" alignment "`n" Tabs[A_Index] "`n" Round((Position / 100) * 1440) "`n----------------"
      }
    
    ; PFA_CENTER  :=  0x3,  PFA_LEFT  :=  0x1, PFA_RIGHT  :=  0x2, PFM_ALIGNMENT  :=  0x8
    ; EM_SETPARAFORMAT := 0x447 ; EM_GETPARAFORMAT := 0x43D
    ; PFM_TABSTOPS = 0x10

    VarSetCapacity(_tmp1, 156, Chr(0))                                            ; PARAFORMAT struct
    NumPut(156, _tmp1, 0, "Int")                                                ; cbSize
    NumPut(0x10, _tmp1, 4)                                                        ; dwMask
    NumPut(TabCount, _tmp1, 26, "UShort")                                            ; tabcount
    NumPut(Tabs, _tmp1, 28, "UInt") ;
    DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0x447, "UInt", "0", "UInt", &_tmp1)
    VarSetCapacity(_tmp1, -1)
  Return
  }
 

can anyone help?...