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

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
fump2000
Posts: 313
Joined: 04 Oct 2013, 17:31

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

31 Jan 2014, 08:37

Is it possible to have a function which recalled when closing using the X that the file was not saved?
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

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

01 Feb 2014, 00:10

The topic of this thread is the class, not the sample script (which was originally written for my own testing). Your function would usually be implemented in a GuiClose or OnExit subroutine. You might call the IsModified() method to check for unsaved changes, but as pointed out here, this might not work reliably on Win 7+.
User avatar
fump2000
Posts: 313
Joined: 04 Oct 2013, 17:31

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

03 Feb 2014, 09:53

Okay thank you! Excuse the topic abuse
arcticir
Posts: 693
Joined: 17 Nov 2013, 11:32

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

15 Feb 2014, 07:07

Hello, I wanted to write one for literary creation software, with RichEdit(can set line spacing), Similar Catlooking.
Catlooking is a software used to concentrate on writing, This page has a video introduction.
It has a characteristic: always automatically adjust the position of the text, has remained in the middle.
I do not know how to achieve This effect, you can help me? This effect can be seen here.

Image

Sorry, my English is poor, I do not know how to express correctly.
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

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

17 Feb 2014, 00:42

Sorry, but I haven't a clue how to achieve this, too.

(My English is poor, too. Thus I don't detect other 'poor' English.)
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

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

17 Feb 2014, 00:52

vielleicht, HTML-JQuery mit ActiveX ?
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

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

17 Feb 2014, 12:00

ActiveX may be an option, but that's not my playground.
arcticir
Posts: 693
Joined: 17 Nov 2013, 11:32

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

18 Feb 2014, 05:36

Thanks. I am also not interested in ActiveX.
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

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

03 Mar 2014, 11:43

* update on 2014-03-03 *
DigiDon
Posts: 178
Joined: 19 May 2014, 04:55
Contact:

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

19 May 2014, 05:29

Hi Just Me, hi everyone!

Waw! I was really impressed by your work just me, you achieved something really great here :!: :!:
I was totally fed up with the ridiculous featureless Notepad and the heavy Word-style software!
That was something that was really missing! ;) I hope many people will enjoy it! (I do!!)

Anyway, I tweaked a lil' bit your great sample script in order to be able to have multiple files/notes opened at the same time and to be able to call it as a function.
I added a "NEW" menu entry to the File menu. It simply opens a new rich edit GUI along with the current one.

Maybe you can make it available as a side sample if you find any interest in it.

I am unsure whether I managed to recover all options but I guess it is pretty close.
Don't hesitate to report broken features or bugs.


Details:
In this exemple the Gui N°70 to 99 are allocated to these notes and are automatically set according to the available ones (I do a try to see if the Gui number is already used)
I first added %A_Gui% to object and variable names but as a result all right clic context menu actions were not working cause A_Gui was not set by the context menu, so I used a workaround by using a duplicate variable called CurrentGuiN set by RE2MessageHandler - which recognize A_Gui well.

Code:

Code: Select all

; ; ======================================================================================================================
; Class RichEdit Demo
; ======================================================================================================================
#NoEnv
SendMode, Input
GUI_RichNoteEditor()
return

; ======================================================================================================================
; Create a Gui with RichEdit controls
; ======================================================================================================================
NEWRichEdit:
GUI_RichNoteEditor()
return

GUI_RichNoteEditor(FileToOpen="")
{
global
SetBatchLines, -1
SetWinDelay, -1
SetControlDelay, -1
if !(GuiNum)
	{
	; SB Helptext ----------------------------------------------------------------------------------------------------------
	SBHelp := {"BTSTB": "Bold (Alt+B)"
         , "BTSTI": "Italic (Alt+I)"
         , "BTSTU": "Underline (Alt+U)"
         , "BTSTS": "Strikeout (Alt+S)"
         , "BTSTH": "Superscript (Ctrl+Shift+""+"")"
         , "BTSTL": "Subscript (Ctrl+""+"")"
         , "BTSTN": "Normal (Alt+N)"
         , "BTTXC": "Text color (Alt+T)"
         , "BTBGC": "Text backcolor"
         , "BTCHF": "Choose font"
         , "BTSIP": "Increase size (Alt+""+"")"
         , "BTSIM": "Decrease size (Alt+""-"")"
         , "BTTAL": "Align left (Ctrl+L)"
         , "BTTAC": "Align center (Ctrl+E)"
         , "BTTAR": "Align right (Ctrl+R)"
         , "BTTAJ": "Align justified"
         , "BTL10": "Linespacing 1 line (Ctrl+1)"
         , "BTL15": "Linespacing 1,5 lines (Ctrl+5)"
         , "BTL20": "Linespacing 2 lines (Ctrl+2)"}
	; Menus ----------------------------------------------------------------------------------------------------------------
	Menu, Zoom, Add, 200 `%, Zoom
	Menu, Zoom, Add, 150 `%, Zoom
	Menu, Zoom, Add, 125 `%, Zoom
	Menu, Zoom, Add, 100 `%, Zoom100
	Menu, Zoom, Check, 100 `%
	Menu, Zoom, Add, 75 `%, Zoom
	Menu, Zoom, Add, 50 `%, Zoom
	Menu, File, Add, &Open, FileOpen
	Menu, File, Add, &New, NEWRichEdit
	Menu, File, Add, &Append, FileAppend
	Menu, File, Add, &Insert, FileInsert
	Menu, File, Add, &Close, FileClose
	Menu, File, Add, &Save, FileSave
	Menu, File, Add, Save &as, FileSaveAs
	Menu, File, Add
	Menu, File, Add, Page &Margins, PageSetup
	Menu, File, Add, &Print, Print
	Menu, File, Add
	Menu, File, Add, &Exit, RichEditGuiClose
	Menu, Edit, Add, &Undo`tCtrl+Z, Undo
	Menu, Edit, Add, &Redo`tCtrl+Y, Redo
	Menu, Edit, Add
	Menu, Edit, Add, C&ut`tCtrl+X, Cut
	Menu, Edit, Add, &Copy`tCtrl+C, Copy
	Menu, Edit, Add, &Paste`tCtrl+V, Paste
	Menu, Edit, Add, C&lear`tDel, Clear
	Menu, Edit, Add
	Menu, Edit, Add, Select &all `tCtrl+A, SelALL
	Menu, Edit, Add, &Deselect all, Deselect
	Menu, Search, Add, &Find, Find
	Menu, Search, Add, &Replace, Replace
	Menu, Alignment, Add, Align &left`tCtrl+L, AlignLeft
	Menu, Alignment, Add, Align &center`tCtrl+E, AlignCenter
	Menu, Alignment, Add, Align &right`tCtrl+R, AlignRight
	Menu, Alignment, Add, Align &justified, AlignRight
	Menu, Indentation, Add, &Set, Indentation
	Menu, Indentation, Add, &Reset, ResetIndentation
	Menu, LineSpacing, Add, 1 line`tCtrl+1, Spacing10
	Menu, LineSpacing, Add, 1.5 lines`tCtrl+5, Spacing15
	Menu, LineSpacing, Add, 2 lines`tCtrl+2, Spacing20
	Menu, Numbering, Add, &Set, Numbering
	Menu, Numbering, Add, &Reset, ResetNumbering
	Menu, Tabstops, Add, &Set Tabstops, SetTabstops
	Menu, Tabstops, Add, &Reset to Default, ResetTabStops
	Menu, Tabstops, Add
	Menu, Tabstops, Add, Set &Default Tabs, SetDefTabs
	Menu, ParaSpacing, Add, &Set, ParaSpacing
	Menu, ParaSpacing, Add, &Reset, ResetParaSpacing
	Menu, Paragraph, Add, &Alignment, :Alignment
	Menu, Paragraph, Add, &Indentation, :Indentation
	Menu, Paragraph, Add, &Numbering, :Numbering
	Menu, Paragraph, Add, &Linespacing, :LineSpacing
	Menu, Paragraph, Add, &Space before/after, :ParaSpacing
	Menu, Paragraph, Add, &Tabstops, :Tabstops
	Menu, Character, Add, &Font, ChooseFont
	Menu, TextColor, Add, &Choose, MTextColor
	Menu, TextColor, Add, &Auto, MTextColor
	Menu, Character, Add, &Text color, :TextColor
	Menu, TextBkColor, Add, &Choose, MTextBkColor
	Menu, TextBkColor, add, &Auto, MTextBkColor
	Menu, Character, Add, Text &Backcolor, :TextBkColor
	Menu, Format, Add, &Character, :Character
	Menu, Format, Add, &Paragraph, :Paragraph
	MenuWordWrap := "&Word-wrap"
	Menu, View, Add, %MenuWordWrap%, WordWrap
	MenuWysiwyg := "Wrap as &printed"
	Menu, View, Add, %MenuWysiwyg%, Wysiwyg
	Menu, View, Add, &Zoom, :Zoom
	Menu, View, Add
	Menu, Background, Add, &Choose, BackGroundColor
	Menu, Background, Add, &Auto, BackgroundColor
	Menu, View, Add, &Background Color, :Background
	Menu, View, Add, &URL Detection, AutoURLDetection
	Menu, GuiMenu, Add, &File, :File
	Menu, GuiMenu, Add, &Edit, :Edit
	Menu, GuiMenu, Add, &Search, :Search
	Menu, GuiMenu, Add, F&ormat, :Format
	Menu, GuiMenu, Add, &View, :View
	Menu, ContextMenu, Add, &Edit, :Edit
	Menu, ContextMenu, Add, &File, :File
	Menu, ContextMenu, Add, &Search, :Search
	Menu, ContextMenu, Add, &Format, :Format
	Menu, ContextMenu, Add, &View, :View
	}
; Initial values -------------------------------------------------------------------------------------------------------
EditW := 800
EditH := 400
MarginX := 10
MarginY := 10
BackColor := "Auto"
FontName := "Arial"
FontSize := "10"
FontStyle := "N"
FontCharSet := 1
TextColor := "Auto"
TextBkColor := "Lime"
WordWrap := False
AutoURL := True
Zoom := "100 %"
ShowWysiwyg := False
CurrentLine := 0
CurrentLineCount := 0
HasFocus := False
; Main Gui -------------------------------------------------------------------------------------------------------------
;------------------------------ADDED : ALLOW UP TO 20 SIMULTANEOUSLY OPENED NOTE WITH GUI NUMBER BETWEEN 70 AND 99
GuiNum=70
Gui %GuiNum%:Default
;Find the available Gui number by trying to add the statusbar
loop 20
	{
try  Gui, Add, Statusbar
	catch e  ; Handles the error/exception
		{
		GuiNum := GuiNum + 1
		if GuiNum=99
			{
			msgbox sorry but you cannot currently have more than 20 notes opened at the same time
			exit
			}
		Gui %GuiNum%:Default
		continue
		}
		break
	}
GuiNumInstance:=GuiNum-69
CurrentGuiN:=GuiNum
if !(FileToOpen)
	GuiTitle= Rich Note Edit N°%GuiNumInstance%
else
	GuiTitle := FileToOpen
Gui, +ReSize +MinSize400x200 +hwndGuiID
Gui %GuiNum%:+LabelRichEditGui
;------------------------------
Gui, Menu, GuiMenu
Gui, Margin, %MarginX%, %MarginY%
; Style buttons
Gui, Font, Bold, Arial
Gui, Add, Button, xm y3 w20 h20 vBTSTB gSetFontStyle, &B
Gui, Font, Norm Italic
Gui, Add, Button, x+0 yp wp hp vBTSTI gSetFontStyle, &I
Gui, Font, Norm Underline
Gui, Add, Button, x+0 yp wp hp vBTSTU gSetFontStyle, &U
Gui, Font, Norm Strike
Gui, Add, Button, x+0 yp wp hp vBTSTS gSetFontStyle, &S
Gui, Font, Norm, Arial
Gui, Add, Button, x+0 yp wp hp vBTSTH gSetFontStyle, % Chr(175)
Gui, Add, Button, x+0 yp wp hp vBTSTL gSetFontStyle, _
Gui, Add, Button, x+0 yp wp hp vBTSTN gSetFontStyle, &N
Gui, Add, Button, x+10 yp wp hp vBTTXC gBTextColor, &T
Gui, Add, Progress, x+0 yp wp hp BackgroundYellow cNavy Border, 50
Gui, Add, Button, x+0 yp wp hp vBTBGC gBTextBkColor, B
Gui, Add, Edit, x+10 yp w150 hp ReadOnly vFNAME, %FontName%
Gui, Add, Button, x+0 yp w20 hp vBTCHF gChooseFont, ...
Gui, Add, Button, x+5 yp wp hp vBTSIP gChangeSize, &+
Gui, Add, Edit, x+0 yp w30 hp ReadOnly vFSIZE, %FontSize%
Gui, Add, Button, x+0 yp w20 hp vBTSIM gChangeSize, &-
; RichEdit #1
Gui, Font, Bold Italic, Arial
try Gui, Add, Text, x+10 yp hp vT1, WWWWWWWW
GuiControlGet, T, Pos, T1
TX := EditW - TW + MarginX
GuiControl, Move, T1, x%TX%
Gui, Font, s8, Arial
Options := " x" . TX . " y" . TY . " w" . TW . " h" . TH
RE%GuiNum%1 := New RichEdit(GuiNum, Options, False)
RE%GuiNum%1.ReplaceSel("AaBbYyZz")
RE%GuiNum%1.AlignText("CENTER")
RE%GuiNum%1.SetOptions(["READONLY"], "SET")
Gui, Font, Norm, Arial
; Alignment & line spacing
Gui, Add, Text, xm y+2 w%EditW% h2 0x1000
Gui, Add, Button, x10 y+1 w30 h20 vBTTAL gAlignLeft, |<
Gui, Add, Button, x+0 yp wp hp vBTTAC gAlignCenter, ><
Gui, Add, Button, x+0 yp wp hp vBTTAR gAlignRight, >|
Gui, Add, Button, x+0 yp wp hp vBTTAJ gAlignJustify, |<>|
Gui, Add, Button, x+10 yp wp hp vBTL10 gSpacing10, 1
Gui, Add, Button, x+0 yp wp hp vBTL15 gSpacing15, % "1" . Chr(189)
Gui, Add, Button, x+0 yp wp hp vBTL20 gSpacing20, 2
; RichEdit #2
Gui, Font, s10, Arial
Options := "xm y+5 w" . EditW . " r20 gRE2MessageHandler" ; " h" . EditH
RE%GuiNum%2 := New RichEdit(GuiNum, Options)
GuiControlGet, RE, Pos, % RE%GuiNum%2.HWND
RE%GuiNum%2.SetBkgndColor(BackColor)
RE%GuiNum%2.SetEventMask(["SELCHANGE"])
;------------------------------ADDED: FILE LOADING
if (FileToOpen)
	{
	RE%GuiNum%2.LoadRTF(FileToOpen)
	Open_File%GuiNum%:=FileToOpen
	}
RE%GuiNum%2.AutoURL(1)
RE%GuiNum%2.WordWrap(1)
RE%GuiNum%2.SetModified()
;------------------------------
Gui, Font
; The rest
SB_SetParts(10, 200)
GuiW := GuiH := 0
Gui Show, , %GuiTitle%
OnMessage(WM_MOUSEMOVE := 0x200, "ShowSBHelp")
GuiControl, Focus, % RE%GuiNum%2.HWND
;FORCE CurrentGuiN (sometimes went wrong probably because of messagehandler procedure)
CurrentGuiN:=GuiNum
GoSub, UpdateGui
;restore default delays
SetBatchLines, 10
SetWinDelay, 100
SetControlDelay, 20
}
; ======================================================================================================================
; End of auto-execute section
; ======================================================================================================================
; ----------------------------------------------------------------------------------------------------------------------
; Testing
^+f::
   RE%CurrentGuiN%2.FindText("Test", ["Down"])
Return
; ----------------------------------------------------------------------------------------------------------------------
ShowSBHelp() {
   Global SBHelp, GuiNum
   Static Current := 0
   If (A_Gui = GuiNum) && (A_GuiControl <> Current)
      SB_SetText(SBHelp[(Current := A_GuiControl)], 3)
   Return
}
; ----------------------------------------------------------------------------------------------------------------------
RE2MessageHandler:
If (A_Gui!=CurrentGuiN)
	CurrentGuiN:=A_Gui
If (A_GuiEvent = "N") && (NumGet(A_EventInfo + 0, A_PtrSize * 2, "Int") = 0x0702) ; EN_SELCHANGE
	{
   SetTimer, UpdateGui, -10
   }
Else {
   If (A_EventInfo = 0x0100) ; EN_SETFOCUS
	   {
		  HasFocus := True
		 }
   Else If (A_EventInfo = 0x0200) ; EN_KILLFOCUS
	   {
		  HasFocus := False
		 }
	}
Return
#If (HasFocus)
; FontStyles
^!b::  ; bold
^!h::  ; superscript
^!i::  ; italic
^!l::  ; subscript
^!n::  ; normal
^!p::  ; protected
^!s::  ; strikeout
^!u::  ; underline
RE%CurrentGuiN%2.ToggleFontStyle(SubStr(A_ThisHotkey, 3))
GoSub, UpdateGui
Return
#If
; ----------------------------------------------------------------------------------------------------------------------
UpdateGui:
Font := RE%CurrentGuiN%2.GetFont()
If (FontName != Font.Name || FontCharset != Font.CharSet || FontStyle != Font.Style || FontSize != Font.Size
|| TextColor != Font.Color || TextBkColor != Font.BkColor) {
   FontStyle := Font.Style
   TextColor := Font.Color
   TextBkColor := Font.BkColor
   FontCharSet := Font.CharSet
   If (FontName != Font.Name) {
      FontName := Font.Name
      GuiControl, , FNAME, %FontName%
   }
   If (FontSize != Font.Size) {
      FontSize := Round(Font.Size)
      GuiControl, , FSIZE, %FontSize%
   }
   Font.Size := 8
   RE%CurrentGuiN%1.SetSel(0, -1) ; select all
   RE%CurrentGuiN%1.SetFont(Font)
   RE%CurrentGuiN%1.SetSel(0, 0)  ; deselect all
}
Stats := RE%CurrentGuiN%2.GetStatistics()
;ADDED : REQUIRED TO UPDATE CORRECTLY
Gui %CurrentGuiN%:Default
SB_SetText(Stats.Line . " : " . Stats.LinePos . " (" . Stats.LineCount . ")  [" . Stats.CharCount . "]", 2)
Return
; ======================================================================================================================
; Gui related
; ======================================================================================================================
RichEditGuiClose:
If RE%CurrentGuiN%2.IsModified() 
	{
	Gui, +OwnDialogs
	MsgBox, 35, Close File, Content has been modified!`nDo you want to save changes?
	IfMsgBox, Cancel
		{
		 GuiControl, Focus, % RE%CurrentGuiN%2.HWND
		 Return
		}
	IfMsgBox, Yes
		GoSub, FileSave
	}
If IsObject(RE%CurrentGuiN%1)
	RE%CurrentGuiN%1 := ""
If IsObject(RE%CurrentGuiN%2)
	RE%CurrentGuiN%2 := ""
Gui, %A_Gui%:Destroy
return
; ----------------------------------------------------------------------------------------------------------------------
RichEditGuiSize:
Critical
If (A_EventInfo = 1)
   Return
If (GuiW = 0) {
   GuiW := A_GuiWidth
   GuiH := A_GuiHeight
   Return
}
If (A_GuiWidth != GuiW || A_GuiHeight != GuiH) {
   REW += A_GuiWidth - GuiW
   REH += A_GuiHeight - GuiH
   GuiControl, Move, % RE%CurrentGuiN%2.HWND, w%REW% h%REH%
   GuiW := A_GuiWidth
   GuiH := A_GuiHeight
}
Return
; ----------------------------------------------------------------------------------------------------------------------
RichEditGuiContextMenu:
CurrentGuiN:=A_Gui
MouseGetPos, , , , HControl, 2
WinGetClass, Class, ahk_id %HControl%
If (Class = RichEdit.Class)
   Menu, ContextMenu, Show
Return
; ======================================================================================================================
; Text operations
; ======================================================================================================================
SetFontStyle:
RE%CurrentGuiN%2.ToggleFontStyle(SubStr(A_GuiControl, 0))
GoSub, UpdateGui
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
ChangeSize:
Size := RE%CurrentGuiN%2.ChangeFontSize(SubStr(A_GuiControl, 0) = "P" ? 1 : -1)
GoSub, UpdateGui
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ======================================================================================================================
; Menu File
; ======================================================================================================================
FileAppend:
FileOpen:
FileInsert:
If (File := RichEditDlgs.FileDlg(RE%CurrentGuiN%2, "O")) {
   RE%CurrentGuiN%2.LoadFile(File, SubStr(A_ThisLabel, 5))
   If (A_ThisLabel = "FileOpen") {
      Gui, +LastFound
      WinGetTitle, Title
      StringSplit, Title, Title, -, %A_Space%
      WinSetTitle, %Title1% - %File%
      Open_File%CurrentGuiN% := File
   }
   GoSub, UpdateGui
}
RE%CurrentGuiN%2.SetModified()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
FileClose:
If (Open_File%CurrentGuiN%) {
   If RE%CurrentGuiN%2.IsModified() {
      Gui, +OwnDialogs
      MsgBox, 35, Close File, Content has been modified!`nDo you want to save changes?
      IfMsgBox, Cancel
      {
         GuiControl, Focus, % RE%CurrentGuiN%2.HWND
         Return
      }
      IfMsgBox, Yes
         GoSub, FileSave
   }
   If RE%CurrentGuiN%2.SetText() {
      Gui, +LastFound
      WinGetTitle, Title
      StringSplit, Title, Title, -, %A_Space%
      WinSetTitle, %Title1%
      Open_File%CurrentGuiN% := ""
   }
   GoSub, UpdateGui
}
RE%CurrentGuiN%2.SetModified()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
FileSave:
If !(Open_File%CurrentGuiN%) {
   GoSub, FileSaveAs
   Return
}
RE%CurrentGuiN%2.SaveFile(Open_File%CurrentGuiN%)
RE%CurrentGuiN%2.SetModified()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
FileSaveAs:
If (File := RichEditDlgs.FileDlg(RE%CurrentGuiN%2, "S")) {
   RE%CurrentGuiN%2.SaveFile(File)
   Gui, +LastFound
   WinGetTitle, Title
   StringSplit, Title, Title, -, %A_Space%
   WinSetTitle, %Title1% - %File%
   Open_File%CurrentGuiN% := File
}
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
PageSetup:
RichEditDlgs.PageSetup(RE%CurrentGuiN%2)
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
Print:
RE%CurrentGuiN%2.Print()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ======================================================================================================================
; Menu Edit
; ======================================================================================================================
Undo:
RE%CurrentGuiN%2.Undo()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
Redo:
RE%CurrentGuiN%2.Redo()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
Cut:
RE%CurrentGuiN%2.Cut()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
Copy:
RE%CurrentGuiN%2.Copy()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
Paste:
RE%CurrentGuiN%2.Paste()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
Clear:
RE%CurrentGuiN%2.Clear()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
SelAll:
RE%CurrentGuiN%2.SelAll()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
Deselect:
RE%CurrentGuiN%2.Deselect()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ======================================================================================================================
; Menu View
; ======================================================================================================================
WordWrap:
WordWrap ^= True
RE%CurrentGuiN%2.WordWrap(WordWrap)
Menu, %A_ThisMenu%, ToggleCheck, %A_ThisMenuItem%
If (WordWrap)
   Menu, %A_ThisMenu%, Disable, %MenuWysiwyg%
Else
   Menu, %A_ThisMenu%, Enable, %MenuWysiwyg%
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
Zoom:
Zoom100:
Menu, Zoom, UnCheck, %Zoom%
If (A_ThisLabel = "Zoom100")
   Zoom := "100 %"
Else
   Zoom := A_ThismenuItem
Menu, Zoom, Check, %Zoom%
RegExMatch(Zoom, "\d+", Ratio)
RE%CurrentGuiN%2.SetZoom(Ratio)
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
WYSIWYG:
ShowWysiwyg ^= True
If (ShowWysiwyg)
   GoSub, Zoom100
RE%CurrentGuiN%2.WYSIWYG(ShowWysiwyg)
Menu, %A_ThisMenu%, ToggleCheck, %A_ThisMenuItem%
If (ShowWysiwyg)
   Menu, %A_ThisMenu%, Disable, %MenuWordWrap%
Else
   Menu, %A_ThisMenu%, Enable, %MenuWordWrap%
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
BackgroundColor:
If InStr(A_ThisMenuItem, "Auto")
   RE%CurrentGuiN%2.SetBkgndColor("Auto")
Else If ((NC := RichEditDlgs.ChooseColor(RE%CurrentGuiN%2, BackColor)) <> "")
   RE%CurrentGuiN%2.SetBkgndColor(BackColor := BGC := NC)
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
AutoURLDetection:
RE%CurrentGuiN%2.AutoURL(AutoURL ^= True)
Menu, %A_ThisMenu%, ToggleCheck, %A_ThisMenuItem%
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ======================================================================================================================
; Menu Character
; ======================================================================================================================
ChooseFont:
RichEditDlgs.ChooseFont(RE%CurrentGuiN%2)
Font := RE%CurrentGuiN%2.GetFont()
Gui, ListView, FNAME
LV_Modify(1, "", Font.Name)
Gui, ListView, FSIZE
LV_Modify(1, "", Font.Size)
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
MTextColor:    ; menu label
BTextColor:    ; button label
If (A_ThisLabel = "MTextColor") && InStr(A_ThisMenuItem, "Auto")
   RE%CurrentGuiN%2.SetFont({Color: "Auto"}), TXC := ""
Else If (StrLen(NC := RichEditDlgs.ChooseColor(RE%CurrentGuiN%2, "T")) <> "")
   RE%CurrentGuiN%2.SetFont({Color: NC}), TXC := NC
ControlFocus,, % "ahk_id " . RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
MTextBkColor:  ; menu label
BTextBkColor:  ; button label
If (A_ThisLabel = "MTextBkColor") && InStr(A_ThisMenuItem, "Auto")
    RE%CurrentGuiN%2.SetFont({BkColor: "Auto"}), TBC := ""
Else If (StrLen(NC := RichEditDlgs.ChooseColor(RE%CurrentGuiN%2, "B")) <> "")
   RE%CurrentGuiN%2.SetFont({BkColor: NC}), TBC := NC
ControlFocus,, % "ahk_id " . RE%CurrentGuiN%2.HWND
Return
; ======================================================================================================================
; Menu Paragraph
; ======================================================================================================================
AlignLeft:
AlignCenter:
AlignRight:
AlignJustify:
RE%CurrentGuiN%2.AlignText({AlignLeft: 1, AlignRight: 2, AlignCenter: 3, AlignJustify: 4}[A_ThisLabel])
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
Indentation:
ParaIndentGui(RE%CurrentGuiN%2)
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
ResetIndentation:
RE%CurrentGuiN%2.SetParaIndent()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
Numbering:
ParaNumberingGui(RE%CurrentGuiN%2)
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
ResetNumbering:
RE%CurrentGuiN%2.SetParaNumbering()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
ParaSpacing:
ParaSpacingGui(RE%CurrentGuiN%2)
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
ResetParaSpacing:
RE%CurrentGuiN%2.SetParaSpacing()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
Spacing10:
Spacing15:
Spacing20:
RegExMatch(A_ThisLabel, "\d+$", S)
RE%CurrentGuiN%2.SetLineSpacing(S / 10)
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
SetTabStops:
SetTabStopsGui(RE%CurrentGuiN%2)
Return
ResetTabStops:
RE%CurrentGuiN%2.SetTabStops()
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ----------------------------------------------------------------------------------------------------------------------
SetDefTabs:
RE%CurrentGuiN%2.SetDefaultTabs(1)
GuiControl, Focus, % RE%CurrentGuiN%2.HWND
Return
; ======================================================================================================================
; Menu Search
; ======================================================================================================================
Find:
RichEditDlgs.FindText(RE%CurrentGuiN%2)
Return
; ----------------------------------------------------------------------------------------------------------------------
Replace:
RichEditDlgs.ReplaceText(RE%CurrentGuiN%2)
Return
; ======================================================================================================================
; ParaIndentation GUI
; ======================================================================================================================
ParaIndentGui(RE) {
   Static Owner := ""
        , Success := False
   Metrics := RE.GetMeasurement()
   PF2 := RE.GetParaFormat()
   Owner := RE.GuiName
   Gui, ParaIndentGui: New
   Gui, +Owner%Owner% +ToolWindow +LastFound +LabelParaIndentGui
   Gui, Margin, 20, 10
   Gui, Add, Text, Section h20 0x200, First line left indent (absolute):
   Gui, Add, Text, xs hp 0x200, Other lines left indent (relative):
   Gui, Add, Text, xs hp 0x200, All lines right indent (absolute):
   Gui, Add, Edit, ys hp Limit5 hwndhLeft1
   Gui, Add, Edit, hp Limit6 hwndhLeft2
   Gui, Add, Edit, hp Limit5 hwndhRight
   Left1 := Round((PF2.StartIndent / 1440) * Metrics, 2)
   If (Metrics = 2.54)
      Left1 := RegExReplace(Left1, "\.", ",")
   GuiControl, , %hLeft1%, %Left1%
   Left2 := Round((PF2.Offset / 1440) * Metrics, 2)
   If (Metrics = 2.54)
      Left2 := RegExReplace(Left2, "\.", ",")
   GuiControl, , %hLeft2%, %Left2%
   Right := Round((PF2.RightIndent / 1440) * Metrics, 2)
   If (Metrics = 2.54)
      Right := RegExReplace(Right, "\.", ",")
   GuiControl, , %hRight%, %Right%
   Gui, Add, Button, xs gParaIndentGuiApply hwndhBtn1, Apply
   Gui, Add, Button, x+10 yp gParaIndentGuiClose hwndhBtn2, Cancel
   GuiControlGet, B, Pos, %hBtn2%
   GuiControl, Move, %hBtn1%, w%BW%
   GuiControlGet, E, Pos, %hLeft1%
   GuiControl, Move, %hBtn2%, % "x" . (EX + EW - BW)
   Gui, %Owner%:+Disabled
   Gui, Show, , Paragraph Indentation
   WinWaitActive
   WinWaitClose
   Return Success
   ; -------------------------------------------------------------------------------------------------------------------
   ParaIndentGuiClose:
      Success := False
      Gui, %Owner%:-Disabled
      Gui, Destroy
   Return
   ; -------------------------------------------------------------------------------------------------------------------
   ParaIndentGuiApply:
      GuiControlGet, Start, , %hLeft1%
      If !RegExMatch(Start, "^\d{1,2}((\.|,)\d{1,2})?$") {
         GuiControl, , %hLeft1%
         GuiControl, Focus, %hLeft1%
         Return
      }
      GuiControlGet, Offset, , %hLeft2%
      If !RegExMatch(Offset, "^(-)?\d{1,2}((\.|,)\d{1,2})?$") {
         GuiControl, , %hLeft2%
         GuiControl, Focus, %hLeft2%
         Return
      }
      GuiControlGet, Right, , %hRight%
      If !RegExMatch(Right, "^\d{1,2}((\.|,)\d{1,2})?$") {
         GuiControl, , %hRight%
         GuiControl, Focus, %hRight%
         Return
      }
      Success := RE.SetParaIndent({Start: Start, Right: Right, Offset: Offset})
      Gui, %Owner%:-Disabled
      Gui, Destroy
   Return
}
; ======================================================================================================================
; ParaNumbering GUI
; ======================================================================================================================
ParaNumberingGui(RE) {
   Static Owner := ""
        , Bullet := "•"
        , PFN := ["Bullet", "Arabic", "LCLetter", "UCLetter", "LCRoman", "UCRoman"]
        , PFNS := ["Paren", "Parens", "Period", "Plain", "None"]
        , Success := False
   Metrics := RE.GetMeasurement()
   PF2 := RE.GetParaFormat()
   Owner := RE.GuiName
   Gui, ParaNumberingGui: New
   Gui, +Owner%Owner% +ToolWindow +LastFound +LabelParaNumberingGui
   Gui, Margin, 20, 10
   Gui, Add, Text, Section h20 w100 0x200, Type:
   Gui, Add, DDL, xp y+0 wp AltSubmit hwndhType, %Bullet%|0, 1, 2|a, b, c|A, B, C|i, ii, iii|I, I, III
   If (PF2.Numbering)
      GuiControl, Choose, %hType%, % PF2.Numbering
   Gui, Add, Text, xs h20 w100 0x200, Start with:
   Gui, Add, Edit, y+0 wp hp Limit5 hwndhStart
   GuiControl, , %hStart%, % PF2.NumberingStart
   Gui, Add, Text, ys h20 w100 0x200, Style:
   Gui, Add, DDL, y+0 wp AltSubmit hwndhStyle Choose1, 1)|(1)|1.|1|w/o
   If (PF2.NumberingStyle)
      GuiControl, Choose, %hStyle%, % ((PF2.NumberingStyle // 0x0100) + 1)
   Gui, Add, Text, h20 w100 0x200, % "Distance:  (" . (Metrics = 1.00 ? "in." : "cm") . ")"
   Gui, Add, Edit, y+0 wp hp Limit5 hwndhDist
   Tab := Round((PF2.NumberingTab / 1440) * Metrics, 2)
   If (Metrics = 2.54)
      Tab := RegExReplace(Tab, "\.", ",")
   GuiControl, , %hDist%, %tab%
   Gui, Add, Button, xs gParaNumberingGuiApply hwndhBtn1, Apply
   Gui, Add, Button, x+10 yp gParaNumberingGuiClose hwndhBtn2, Cancel
   GuiControlGet, B, Pos, %hBtn2%
   GuiControl, Move, %hBtn1%, w%BW%
   GuiControlGet, D, Pos, %hStyle%
   GuiControl, Move, %hBtn2%, % "x" . (DX + DW - BW)
   Gui, %Owner%:+Disabled
   Gui, Show, , Paragraph Numbering
   WinWaitActive
   WinWaitClose
   Return Success
   ; -------------------------------------------------------------------------------------------------------------------
   ParaNumberingGuiClose:
      Success := False
      Gui, %Owner%:-Disabled
      Gui, Destroy
   Return
   ; -------------------------------------------------------------------------------------------------------------------
   ParaNumberingGuiApply:
      GuiControlGet, Type, , %hType%
      GuiControlGet, Style, , %hStyle%
      GuiControlGet, Start, , %hStart%
      GuiControlGet, Tab, , %hDist%
      If !RegExMatch(Tab, "^\d{1,2}((\.|,)\d{1,2})?$") {
         GuiControl, , %hDist%
         GuiControl, Focus, %hDist%
         Return
      }
      Numbering := {Type: PFN[Type], Style: PFNS[Style]}
      Numbering.Tab := RegExReplace(Tab, ",", ".")
      Numbering.Start := Start
      Success := RE.SetParaNumbering(Numbering)
      Gui, %Owner%:-Disabled
      Gui, Destroy
   Return
}
; ======================================================================================================================
; ParaSpacing GUI
; ======================================================================================================================
ParaSpacingGui(RE) {
   Static Owner := ""
        , Success := False
   PF2 := RE.GetParaFormat()
   Owner := RE.GuiName
   Gui, ParaSpacingGui: New
   Gui, +Owner%Owner% +ToolWindow +LastFound +LabelParaSpacingGui
   Gui, Margin, 20, 10
   Gui, Add, Text, Section h20 0x200, Space before in points:
   Gui, Add, Text, xs y+10 hp 0x200, Space after in points:
   Gui, Add, Edit, ys hp hwndhBefore Number Limit2 Right, 00
   GuiControl, , %hBefore%, % (PF2.SpaceBefore // 20)
   Gui, Add, Edit, xp y+10 hp hwndhAfter Number Limit2 Right, 00
   GuiControl, , %hAfter%, % (PF2.SpaceAfter // 20)
   Gui, Add, Button, xs gParaSpacingGuiApply hwndhBtn1, Apply
   Gui, Add, Button, x+10 yp gParaSpacingGuiClose hwndhBtn2, Cancel
   GuiControlGet, B, Pos, %hBtn2%
   GuiControl, Move, %hBtn1%, w%BW%
   GuiControlGet, E, Pos, %hAfter%
   X := EX + EW - BW
   GuiControl, Move, %hBtn2%, x%X%
   Gui, %Owner%:+Disabled
   Gui, Show, , Paragraph Spacing
   WinWaitActive
   WinWaitClose
   Return Success
   ; -------------------------------------------------------------------------------------------------------------------
   ParaSpacingGuiClose:
      Success := False
      Gui, %Owner%:-Disabled
      Gui, Destroy
   Return
   ; -------------------------------------------------------------------------------------------------------------------
   ParaSpacingGuiApply:
      GuiControlGet, Before, , %hBefore%
      GuiControlGet, After, , %hAfter%
      Success := RE.SetParaSpacing({Before: Before, After: After})
      Gui, %Owner%:-Disabled
      Gui, Destroy
   Return
}
; ======================================================================================================================
; SetTabStops GUI
; ======================================================================================================================
SetTabStopsGui(RE) {
   ; Set paragraph's tabstobs
   ; Call with parameter mode = "Reset" to reset to default tabs
   ; EM_GETPARAFORMAT = 0x43D, EM_SETPARAFORMAT = 0x447
   ; PFM_TABSTOPS = 0x10
   Static Owner   := ""
        , Metrics := 0
        , MinTab  := 0.30     ; minimal tabstop in inches
        , MaxTab  := 8.30     ; maximal tabstop in inches
        , AL := 0x00000000    ; left aligned (default)
        , AC := 0x01000000    ; centered
        , AR := 0x02000000    ; right aligned
        , AD := 0x03000000    ; decimal tabstop
        , Align := {0x00000000: "L", 0x01000000: "C", 0x02000000: "R", 0x03000000: "D"}
        , TabCount := 0       ; tab count
        , MAX_TAB_STOPS := 32
        , Success := False    ; return value
   Metrics := RE.GetMeasurement()
   PF2 := RE.GetParaFormat()
   TL := ""
   TabCount := PF2.TabCount
   Tabs := PF2.Tabs
   Loop, %TabCount% {
      Tab := Tabs[A_Index]
      TL .= Round(((Tab & 0x00FFFFFF) * Metrics) / 1440, 2) . ":" . (Tab & 0xFF000000) . "|"
   }
   If (TabCount)
      TL := SubStr(TL, 1, -1)
   Owner := RE.GuiName
   Gui, SetTabStopsGui: New
   Gui, +Owner%Owner% +ToolWindow +LastFound +LabelSetTabStopsGui
   Gui, Margin, 10, 10
   Gui, Add, Text, Section, % "Position: (" . (Metrics = 1.00 ? "in." : "cm") . ")"
   Gui, Add, ComboBox, xs y+2 w120 r6 Simple +0x800 hwndCBBID AltSubmit gSetTabStopsGuiSelChanged
   If (TabCount) {
      Loop, Parse, TL, |
      {
         StringSplit, T, A_LoopField, :
         SendMessage, 0x0143, 0, &T1, , ahk_id %CBBID% ; CB_ADDSTRING
         SendMessage, 0x0151, ErrorLevel, T2, , ahk_id %CBBID% ; CB_SETITEMDATA
      }
   }
   Gui, Add, Text, ys Section, Alignment:
   Gui, Add, Radio, xs w60 Section y+2 hwndRLID Checked Group, Left
   Gui, Add, Radio, wp hwndRCID, Center
   Gui, Add, Radio, ys wp hwndRRID, Right
   Gui, Add, Radio, wp hwndRDID, Decimal
   Gui, Add, Button, xs Section w60 gSetTabStopsGuiAdd Disabled hwndBTADDID, &Add
   Gui, Add, Button, ys w60 gSetTabStopsGuiRemove Disabled hwndBTREMID, &Remove
   GuiControlGet, P1, Pos, %BTADDID%
   GuiControlGet, P2, Pos, %BTREMID%
   W := P2X + P2W - P1X
   Gui, Add, Button, xs w%W% gSetTabStopsGuiRemoveAll hwndBTCLAID, &Clear all
   Gui, Add, Text, xm h5
   Gui, Add, Button, xm y+0 w60 gSetTabStopsGuiOK, &OK
   X := P2X + P2W - 60
   Gui, Add, Button, x%X% yp wp gSetTabStopsGuiClose, &Cancel
   Gui, %Owner%:+Disabled
   Gui, Show, , Set Tabstops
   WinWaitActive
   WinWaitClose
   Return Success
   ; -------------------------------------------------------------------------------------------------------------------
   SetTabStopsGuiClose:
      Success := False
      Gui, %Owner%:-Disabled
      Gui, Destroy
   Return
   ; -------------------------------------------------------------------------------------------------------------------
   SetTabStopsGuiSelChanged:
      If (TabCount < MAX_TAB_STOPS) {
         GuiControlGet, T, , %CBBID%, Text
         If RegExMatch(T, "^\s*$")
            GuiControl, Disable, %BTADDID%
         Else
            GuiControl, Enable, %BTADDID%
      }
      SendMessage, 0x0147, 0, 0, , ahk_id %CBBID% ; CB_GETCURSEL
      I := ErrorLevel
      If (I > 0x7FFFFFFF) {
         GuiControl, Disable, %BTREMID%
         Return
      }
      GuiControl, Enable, %BTREMID%
      SendMessage, 0x0150, I, 0, , ahk_id %CBBID% ; CB_GETITEMDATA
      A := ErrorLevel
      C := A = AC ? RCID : A = AR ? RRID : A = AD ? RDID : RLID
      GuiControl, , %C%, 1
   Return
   ; -------------------------------------------------------------------------------------------------------------------
   SetTabStopsGuiAdd:
      GuiControlGet, T, ,%CBBID%, Text
      If !RegExMatch(T, "^\d*[.,]?\d+$") {
         GuiControl, Focus, %CBBID%
         Return
      }
      StringReplace, T, T, `,, .
      T := Round(T, 2)
      If (Round(T / Metrics, 2) < MinTab) {
         GuiControl, Focus, %CBBID%
         Return
      }
      If (Round(T / Metrics, 2) > MaxTab) {
         GuiControl, Focus, %CBBID%
         Return
      }
      GuiControlGet, RL, , %RLID%
      GuiControlGet, RC, , %RCID%
      GuiControlGet, RR, , %RRID%
      GuiControlGet, RD, , %RDID%
      A := RC ? AC : RR ? AR : RD ? AD : AL
      ControlGet, TL, List, , , ahk_id %CBBID%
      P := -1
      Loop, Parse, TL, `n
      {
         If (T < A_LoopField) {
            P := A_Index - 1
            Break
         }
         IF (T = A_LoopField) {
            P := A_Index - 1
            SendMessage, 0x0144, P, 0, , ahk_id %CBBID% ; CB_DELETESTRING
            Break
         }
      }
      SendMessage, 0x014A, P, &T, , ahk_id %CBBID% ; CB_INSERTSTRING
      SendMessage, 0x0151, ErrorLevel, A, , ahk_id %CBBID% ; CB_SETITEMDATA
      TabCount++
      If !(TabCount < MAX_TAB_STOPS)
         GuiControl, Disable, %BTADDID%
      GuiControl, Text, %CBBID%
      GuiControl, Focus, %CBBID%
   Return
   ; -------------------------------------------------------------------------------------------------------------------
   SetTabStopsGuiRemove:
      SendMessage, 0x0147, 0, 0, , ahk_id %CBBID% ; CB_GETCURSEL
      I := ErrorLevel
      If (I > 0x7FFFFFFF)
         Return
      SendMessage, 0x0144, I, 0, , ahk_id %CBBID% ; CB_DELETESTRING
      GuiControl, Text, %CBBID%
      TabCount--
      GuiControl, , %RLID%, 1
      GuiControl, Focus, %CBBID%
   Return
   ; -------------------------------------------------------------------------------------------------------------------
   SetTabStopsGuiRemoveAll:
      GuiControl, , %CBBID%, |
      TabCount := 0
      GuiControl, , %RLID%, 1
      GuiControl, Focus, %CBBID%
   Return
   ; -------------------------------------------------------------------------------------------------------------------
   SetTabStopsGuiOK:
      SendMessage, 0x0146, 0, 0, , ahk_id %CBBID% ; CB_GETCOUNT
      If ((TabCount := ErrorLevel) > 0x7FFFFFFF)
         Return
      If (TabCount > 0) {
         ControlGet, TL, List, , , ahk_id %CBBID%
         TabStops := {}
         Loop, Parse, TL, `n
         {
            SendMessage, 0x0150, A_Index - 1, 0, , ahk_id %CBBID% ; CB_GETITEMDATA
            TabStops[A_LoopField * 100] := Align[ErrorLevel]
         }
      }
      Success := RE.SetTabStops(TabStops)
      Gui, %Owner%:-Disabled
      Gui, Destroy
   Return
}
; ======================================================================================================================
#Include Class_RichEdit.ahk
#Include Class_RichEditDlgs.ahk
; ======================================================================================================================
I will send you a message soon. See ya! ;)
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
Coding takes lots of time and efforts. If I have helped you or if you enjoy one of my free projects, please consider a small donation :thumbup:
Sorry I am working hard at the moment at a new job and can't commit on delays of answers & updates
DigiDon
Posts: 178
Joined: 19 May 2014, 04:55
Contact:

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

19 May 2014, 05:36

By the way, I wanted to get the autoURL really working (meaning that you can click on it to follow the link) and I was looking on the internet to find quite nothing except the official documentation I don't understand (really NOT used to deal with windows messages, MSDN and the like) AND A post in which you were involved and apparently found a solution : http://ahkscript.org/boards/viewtopic.p ... 5&start=20

But after some trials I could NOT make it work :(
The condition If (Msg = 0x070B) { ; EN_LINK seems not to be met on my computer when I click on the link..

I use Autohotkey U64, if that may be the issue

Do you have any idea of what I could try? Of another working solution?
Maybe could you implement it in source?

Thanks! :)
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
Coding takes lots of time and efforts. If I have helped you or if you enjoy one of my free projects, please consider a small donation :thumbup:
Sorry I am working hard at the moment at a new job and can't commit on delays of answers & updates
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

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

19 May 2014, 12:27

:arrow: EN_LINK notification code:
... To receive EN_LINK notification codes, specify the ENM_LINK flag in the mask sent with the EM_SETEVENTMASK message.
Did you do it?
DigiDon
Posts: 178
Joined: 19 May 2014, 04:55
Contact:

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

19 May 2014, 12:38

I admit I have no clue of what that does concretely mean.. :(
Could you shed some light on how to do it? :roll:

I basically tried the script http://ahkscript.org/boards/viewtopic.p ... 781#p13781 as fump2000 said it was working
I simply copy pasted it as I was using your sample script as well as my test base (or more precisely the tweaked version I posted).

Code: Select all

RE2MessageHandler:
If (A_GuiEvent = "N") {
   Msg := NumGet(A_EventInfo + 0, A_PtrSize * 2, "Int")
   If (Msg = 0x0702) { ; EN_SELCHANGE
      SetTimer, UpdateGui, -10
      Return
   }
   If (Msg = 0x070B) { ; EN_LINK
      Message:=NumGet(A_EventInfo + 0, A_PtrSize * 3, "Int")
      If (Message = 0x0202) ; WM_LBUTTONUP
        {
            cpMin:=NumGet(A_EventInfo + 0, A_PtrSize * 6, "Int")
            cpMax:=NumGet(A_EventInfo + 0, (A_PtrSize * 6) + 4, "Int")
            URLtoOpen:=GetTextRange(RE2.HWND, cpMin, cpMax)
            msgbox % URLtoOpen
        }
      Return
   }
} Else {
   If (A_EventInfo = 0x0100) ; EN_SETFOCUS
      HasFocus := True
   Else If (A_EventInfo = 0x0200) ; EN_KILLFOCUS
      HasFocus := False
}
Return
I just put a msgbox after the
If (Msg = 0x070B) { ; EN_LINK
section but I could not see it happening :(
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
Coding takes lots of time and efforts. If I have helped you or if you enjoy one of my free projects, please consider a small donation :thumbup:
Sorry I am working hard at the moment at a new job and can't commit on delays of answers & updates
DigiDon
Posts: 178
Joined: 19 May 2014, 04:55
Contact:

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

19 May 2014, 16:51

If you're looking for technical answer, pass your way, just a funny story
Ahahah! I can't believe it!! :lol: :lol: After the last posts I decided to take a look back at your discussion with fump (http://ahkscript.org/boards/viewtopic.p ... 5&start=20) because I was kind of thinking:
"Wait I guess I'm asking the exact same thing than the OP of the other thread but he (you, just me) still tries to send me back to MSDN even though I said I knew nothing about these messages, masks, and so on.. :roll: Plus the guy and just me seemed to have found a working solution... so why doesn't he (you, just me) just provide me/us the solution?... :roll: There HAS to be something I overlooked!"

After looking on google for a quick dirty answer to no avail I was like "No no no I can't go deep into another subject I know nothing about, it will take me so much time I can't afford right now"
Grrrr... so as I said I decided to grab my courage and look back at the OP post from the beginning and to press the hardest I could my german mastering to figure out what I had missed out..

Ahahah that's when I understood you WOULD NOT provide me with a quick solution and that (maybe) you were pushing me towards the same slippy scarry roads you drove the poor guy into! :lol: :lol:

Guess what?! I thought I never would but I finally found the magic key ! :D
You won't trick me this time just me !! :lol:

But in respect to just me and fump2000 (brave guy BTW ;)) I will let you have some other victims before I provide the solution :D
Ahah, funny story 8-)

PS: Just kidding, I know it is noble and I thank you for sharing your knowledge and trying to teach us, fool ignorants in a hurry ;)
Just made me laugh to read the topic :D
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
Coding takes lots of time and efforts. If I have helped you or if you enjoy one of my free projects, please consider a small donation :thumbup:
Sorry I am working hard at the moment at a new job and can't commit on delays of answers & updates
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

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

20 May 2014, 01:17

Well, it seems you finally got it. Just one hint for all others stumbling across this point of the thread: The class comes with a SetEventMask() method. ;)

DigiDon,

yes, it was hard work for me to basically understand the rich edit control, its features, and how to deal with them. The class may make it easier, but it still helps to have an idea about the technical background if you step down into the depths of this versatile control.
geek
Posts: 1052
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

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

22 Aug 2014, 13:31

License? I'd like to use this to display IRC messages in MyRC, but I don't see any license anywhere.

Also, you need to advertise better or something. I couldn't find anything but cRichEdit and was already ankle-deep in writing my own RichEdit library, having already gotten several methods working properly :facepalm: . Your library is already much more complete than mine ever would have been, so I do hope I can use it
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

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

22 Aug 2014, 15:18

License?
No license!
geek
Posts: 1052
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

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

22 Aug 2014, 15:22

No license means nobody is allowed to use it for anything, personal or commercial. I suppose you mean public domain?
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

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

22 Aug 2014, 15:37

'No license' means, that you don't need a license for anything you want to do.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 118 guests