jlf

GUICtrlCreateEdit with Vscroll & ReadOnly

8 posts in this topic

#1 ·  Posted (edited)

Hi,

   I need to create a text-area (I used GUICtrlCreateEdit) in which some text will be returned. The user should be able to vertical-scroll in this text-box but never be able to edit this text.

   In the attached script, if the user do a click inside this Edit, the next text will be inserted at this location (very very bad for me).

   So, I tryed to "GUI_DISABLE" this Edit. This solve the user-click problem, BUT the user is not anymore able to move the vertical scroll ! :(

   This line is line 26 in the script. (please see also comment just before in this script).

   Question : how to have a "valid" vertical scroll and always insert text at the end, even if user clicks somewhere ?

Thanks in advance for your help ;)

 

JL

test.au3

Edited by jlf

Share this post


Link to post
Share on other sites



jlf,

How about this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>

Opt("GUIOnEventMode", 1)

Local Const $WIDTH = 1000
Local Const $HEIGHT = 600

Local $i = 0

$hnd_gui = GUICreate("Title", $WIDTH, $HEIGHT)
GUISetOnEvent($GUI_EVENT_CLOSE, "_GUI_Close")

$CID_ctrl = GUICtrlCreateEdit("", 0, 0, $WIDTH - 3, $HEIGHT - 25, BitOR($ES_READONLY, $WS_VSCROLL, $ES_AUTOVSCROLL))

GUISetState()

For $i = 1 To 10
    GUICtrlSetData($CID_ctrl, GUICtrlRead($CID_ctrl) & StringFormat("Time Stamp #%d" & @CRLF, $i))
Next

While $hnd_gui <> 0
    GUICtrlSetData($CID_ctrl, GUICtrlRead($CID_ctrl) & StringFormat("Time Stamp #%d" & @CRLF, $i))
    $i += 1
    _GUICtrlEdit_Scroll($CID_ctrl, $SB_SCROLLCARET)
    Sleep(250)
WEnd

Func _GUI_Close()
    Exit
EndFunc   ;==>_GUI_Close

Please ask if you have any questions.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks M23.

I tryed your code, but the text being added is in fact the output stream of a child process. This is expected to be a bit more than 1Mbyte. So I created a "dummy" string and AutoIt drastically slow down @ 256Kbytes.

The problem is, in my opinion, that entire text is each time read and write again, instead of writing only the new part.

I think the best way to start is activating the line with GUI_DISABLE and to solve the problem to NOT disable the vertical scroll. :) I don't know if this is "AutoIt-compatible".

I tryed also the _GUICtrlEdit_InsertText, but the "caret" is still user selectable. So, perhaps another way to solve this : is it possible to disable the caret, and stuck it at the end ? Or disable mouse-click ?

Thanks in advance :)

JL

Share this post


Link to post
Share on other sites

jlf,

Quote

the text being added is in fact the output stream of a child process. This is expected to be a bit more than 1Mbyte

Always helps to explain the problem fully from the start - then we do not waste time on easy, but ultimately useless suggestions.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>

Opt("GUIOnEventMode", 1)

Local Const $WIDTH = 1000
Local Const $HEIGHT = 600

Local $i = 0

$hnd_gui = GUICreate("Title", $WIDTH, $HEIGHT)
GUISetOnEvent($GUI_EVENT_CLOSE, "_GUI_Close")

$CID_ctrl = GUICtrlCreateEdit("", 0, 0, $WIDTH - 3, $HEIGHT - 25, BitOR($ES_READONLY, $WS_VSCROLL, $ES_AUTOVSCROLL))

GUISetState()

While 1
    _GUICtrlEdit_InsertText($CID_ctrl, StringFormat("Time Stamp #%d" & @CRLF, $i))
    $i += 1
    _GUICtrlEdit_Scroll($CID_ctrl, $SB_SCROLLCARET)
    Sleep(250)
WEnd

Func _GUI_Close()
    Exit
EndFunc   ;==>_GUI_Close

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

(re) Thanks M23.

There is still the same problem. Please see attached "image1.png". If user do a click in this window, sometime, the text is inserted at this "wrong" caret position. I really think the problem is the user's ability to click in this text-area.

If the user do a click between the two instructions "InsertText" & "Scroll", the new & bad caret position is used. I also tryed with a code varation, but this doesn't fix the issue.

While $hnd_gui<>0
    _GUICtrlEdit_Scroll($hnd_ctrl, $SB_SCROLLCARET)
    _GUICtrlEdit_InsertText($hnd_ctrl, StringFormat("Time Stamp #%d" & @CRLF,$i))
    _GUICtrlEdit_Scroll($hnd_ctrl, $SB_SCROLLCARET)
    $i += 1
    Sleep(500)
WEnd

 

Thanks in advance.

JL

Image1.png

Share this post


Link to post
Share on other sites

jlf,

I can make that happen very occasionally if I click incessantly in the edit - you must have some very assiduous clickers!

So to prevent any clicking in the edit let us cover it with a transparent child GUI, leaving the scrollbar uncovered:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>

Opt("GUIOnEventMode", 1)

Local Const $WIDTH = 1000
Local Const $HEIGHT = 600

Local $i = 0

$hnd_gui = GUICreate("Title", $WIDTH, $HEIGHT)
GUISetOnEvent($GUI_EVENT_CLOSE, "_GUI_Close")
$CID_ctrl = GUICtrlCreateEdit("", 0, 0, $WIDTH - 3, $HEIGHT - 25, BitOR($ES_READONLY, $WS_VSCROLL, $ES_AUTOVSCROLL))

GUISetState()

; Create child GUI to cover edit control, less the scrollbar
$hGUI_Child = GUICreate("", $WIDTH - 20, $HEIGHT - 25, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $hnd_gui)
; Make this GUI almost transparent
WinSetTrans($hGUI_Child, "", 10)
GUISetState()

While 1
    _GUICtrlEdit_Scroll($CID_ctrl, $SB_SCROLLCARET)
    _GUICtrlEdit_InsertText($CID_ctrl, StringFormat("Time Stamp #%d" & @CRLF, $i))
    $i += 1
    Sleep(250)
    ; If child GUI clicked, restore focus to main GUI
    If BitAnd(WinGetState($hGUI_Child), 8) Then
        WinActivate($hnd_gui)
    EndIf
WEnd

Func _GUI_Close()
    Exit
EndFunc   ;==>_GUI_Close

How about that?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks M23.

This works fine !!!! :):)

JL

Share this post


Link to post
Share on other sites

jlf,

Good - glad I could help.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now