Jump to content

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

[Library] Edit v1.3 - Update/Control any Edit control


  • Please log in to reply
35 replies to this topic
jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
--------------------
Notice: Updates on this topic have been moved here.
--------------------

Introduction
The standard Edit control is a lightweight and surprisingly powerful window control for displaying and editing text. Inspired by the Edit mini-library created by Lexikos and the HiEditor library created by majkinetor, the Edit library was created to help exploit the capabilities of this excellent control.

Screenshots
A couple of screenshots from the examples...

Text-To-Speech_03.jpg
Spell%20Check_03.jpg

The Code
The pertinent files are as follows:
  • Project: Edit.zip (Includes the Edit library, add-on functions, and example scripts)
  • Documentation: Edit Library
Issues/Considerations
  • AutoHotkey v1.1+ and Unicode. Starting with v1.2, the core library, i.e. Edit.ahk, should work with all versions of AutoHotkey, including AutoHotkey v1.1+ Unicode. However, some of the add-on functions, specifically the add-ons for Spell Check and Text-To-Speech, do present a challenge. The following items cover these issues.
  • Spell Check. The Edit_SpellCheckGUI add-on uses the Spell library, the components of which (the Hunspell dynamic link library and the AutoHotkey wrapper) are not Unicode compatible. To use the Edit_SpellCheckGUI add-on, you must use AutoHotkey Basic or the ANSI version of AutoHotkey v1.1+.
  • Text-To-Speech. The default text-to-speech add-on, Edit_TTSGUI, uses the COM library. This add-on will run on AutoHotkey Basic and the ANSI version of AutoHotkey v1.1+ but will not work on the Unicode version of AutoHotkey v1.1+.

    A special version of the Text-To-Speech add-on as been written for AutoHotkey v1.1+. The function name is the same but the library file includes a "_L" at the end of the file name. The "_L" version of the add-on will run on both the ANSI and Unicode versions of AutoHotkey v1.1+.
References
The following posts were helpful in the creation of this library. Thanks to the original authors.Scripts that use the Edit library:---------------------------------------------------------------------------
Release Notes

v0.1 (Preview)
Original release.

v0.2 (Preview)
- The Edit_CharFromPos function has been rewritten to support controls with more than 65,536 characters and/or more than 65,536 lines of text.
- Added Drag & Drop example (thanks Laszlo)

v1.0
- Removed Edit_GetThumb function. Could not get the EM_GETTHUMB message to work on an Edit control. Most documentation implies that the message is for the RichEdit control.

v1.1
- Fix: Edit_PosFromChar function modified to correctly return a negative number if the requested character is outside the edit control.
- Added the Edit_TTSGUI (Preview) add-on function to show a Text-To-Speech player for any edit control. Includes a plethora of options. Requires the COM library.
- Added the Edit_SpellCheckGUI (Preview) add-on function. Requires the Spell library.
- Updated examples.

v1.2
New Functions:
- Edit_ANSI2Unicode [Internal only] - Convert a character string (ANSI) to a UTF-16 (wide character) string.
- Edit_GetCueBanner - Gets the cue banner text for an edit control. [Windows Vista+]
- Edit_HideBalloonTip - Hide balloon tip associated with an edit control.
- Edit_SetCueBanner - Sets the cue banner text for an edit control [Windows XP+].
- Edit_ShowBalloonTip - Display a balloon tip associated with an edit control.
- Edit_Unicode2ANSI [Internal only] - Convert a UTF-16 (wide character) string to a character string (ANSI).

New Add-On Functions:
- Edit_TTSGUI for AutoHotkey v1.1+.

Updates/Enhancements:
- Several functions modified to support Unicode.
- Added new examples. Most of current example scripts have been rewritten or updated.

Bug Fix:
- Edit_GetLimitText - Function was converting return value from UInt (32-bit unsigned integer) to Int (32-bit signed integer) which incorrectly converted values over 2,147,483,647 into negative values. This change may affect the way your script tested for maximum values. See the function documentation or the correct maximum values to test for.

v1.3
New Functions:
- Edit_ActivateParent - Activate (make foremost) the parent window of the Edit control.
- Edit_Disable - Disable the Edit control.
- Edit_DisableAllScrollBars - Disable all scroll bars.
- Edit_DisableHScrollBar - Disable the horizontal scroll bar.
- Edit_DisableVScrollBar - Disable the vertical scroll bar.
- Edit_Enable - Enable the Edit control.
- Edit_EnableAllScrollBars - Enable all scroll bars.
- Edit_EnableHScrollBar - Enable the horizontal scroll bar.
- Edit_EnableVScrollBar - Enable the vertical scroll bar.
- Edit_EnableScrollBar - Enable the specified scroll bar.
- Edit_GetComboBoxEdit - Get the handle of the Edit control attached to a combo box. (thanks just me)
- Edit_GetFont - Get the font of the Edit control.
- Edit_GetParent - Get the handle to the Edit control's parent window.
- Edit_GetPos - Get the position and size of the Edit control.
- Edit_GetScrollBarInfo [Internal only] - Get the information for a scroll bar.
- Edit_GetStyle - Get the styles currently set for the Edit control.
- Edit_HasFocus - Determine if an Edit control has input focus.
- Edit_Hide - Hide an Edit control.
- Edit_HideAllScrollBars - Hide all scroll bars.
- Edit_HideHScrollBar - Hide the horizontal scroll bar.
- Edit_HideVScrollBar - Hide the vertical scroll bar.
- Edit_IsDisabled - Determine if the Edit control is disabled.
- Edit_IsHScrollBarEnabled - Determine if the horizontal scroll bar is enabled.
- Edit_IsHScrollBarVisible - Determine if the horizontal scroll bar is visible.
- Edit_IsVScrollBarEnabled - Determine if the vertical scroll bar is enabled.
- Edit_IsVScrollBarVisible - Determine if the vertical scroll bar is visible.
- Edit_ScrollPage - Scrolls the Edit control by page.
- Edit_SetFocus - Set input focus to the Edit control.
- Edit_SetFont - Set the font of the Edit control.
- Edit_Show - Show the Edit control.
- Edit_ShowAllScrollBars - Show all scroll bars.
- Edit_ShowHScrollBar - Show the horizontal scroll bar.
- Edit_ShowScrollBar - Show the specified scroll bar.
- Edit_ShowVScrollBar - Show the vertical scroll bar.

Updates/Enhancements:
- Added p_SetModify parameter to the Edit_SetText function. If set to TRUE, the modification flag on the Edit control is set after the text is set.
- Edit_LineScroll function modified to support new options: Top, Bottom, Left, and Right.
- Added 6 new examples.


entropic
  • Members
  • 181 posts
  • Last active: Nov 27 2011 03:15 AM
  • Joined: 21 Dec 2008
Very cool, thank you!

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
You could drag text in- and between edit controls. Most of the useful messages are also described there.

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005

You could drag text in- and between edit controls. Most of the useful messages are also described there.

Sound cool. I'll check it out. Thanks. :)

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
v0.2 (Preview)
Minor updates. See the bottom of the first post for a list of changes.

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
v1.0
Superficial changes only. No need to download if you have v0.2 already. See the bottom of the first post for a list of changes.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Well done.

Missing messages include EM_GETSELTEXT, EM_GETTEXTRANGE, and EM_FINDTEXT. ... Although the substitute code/messages are very capable, they are not quite as efficient (memory and/or speed) as the messages they replace (if they existed).

FYI, MSDN explicitly states these messages are for rich edit controls. They're not supposed to work for edit controls.

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005

Missing messages include EM_GETSELTEXT, EM_GETTEXTRANGE, and EM_FINDTEXT. ... Although the substitute code/messages are very capable, they are not quite as efficient (memory and/or speed) as the messages they replace (if they existed).

FYI, MSDN explicitly states these messages are for rich edit controls. They're not supposed to work for edit controls.

Of course. I was just trying to get across that these messages are needed for the Edit control and that the library provides fantabulous :wink: substitutes. I'll try to rewrite this section to avoid confusion. Thank you for your feedback. :)

XYZ
  • Members
  • 224 posts
  • Last active: Apr 29 2010 01:48 PM
  • Joined: 20 Mar 2010

[Library] Edit v1.0 - Update/Control any Edit control


thx a lot man

TLM
  • Administrators
  • 3864 posts
  • Last active:
  • Joined: 21 Aug 2006
Excellent :twisted:

Posted Image

don't duplicate, iterate!


jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
Smart Word Wrap Toggle For Notepad

One of the problems (read: pet peeves) with toggling Word Wrap in Notepad is that the program loses track of where you were in the document. It's not a big deal if you just opened the document or if you're working on the first few lines, but if you were working far into the document, it can be very irritating.

This script provide two basic features:
  • Context-sensitive hotkey. This code will only fire if a Notepad window is active. Uses Ctrl+W (patterned after PSPad) but change it to whatever you want.
  • Preserve caret position or selection. If typing just before the hotkey is used, you can resume typing immediately afterwards. If text was selected before the hotkey is used, the same text will be selected afterwards.
Here's the code (needs the Edit library of course):


I hope that someone finds this useful.

Wicked
  • Members
  • 504 posts
  • Last active: Nov 18 2018 02:17 AM
  • Joined: 07 Jun 2008
I can't believe I've missed this up until this point!

Thank you for your hard work, jballi. It is much appreciated!

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
v1.1
Minor bug fix plus a couple of new add-on functions. See the bottom of the first post for a list of changes.

Mystiq
  • Members
  • 83 posts
  • Last active: Nov 06 2011 07:07 PM
  • Joined: 08 Jan 2007
This is exactly what i was looking for, lo and behold, someone had already made it! :)

Thanks!

tov
  • Guests
  • Last active:
  • Joined: --
Looks looks great :)

I need my edit box to only hold 1000 lines of text, after that I want the top line to be removed and everything else scroll up.

The edit box is being constantly updated by a live stream, using 1000 lines will reduce the memory overhead needed.

I will have a play.. but : Can anyone point me in the right direction ??

Thanks