Jump to content

Autoscroll GuiCtrlCreatEdit, with readonly on!


Recommended Posts

Hello.

I have made a little program now, and in the program i have a log function. And then im writning things to GuiCtrlCreatEdit. But when the text comes to the bottom, it wount scroll down it self. I need to use the mouse, and drag down the roller.

How can i get this to scroll down automatic?

Now the box look like this:

$loggedit = GUICtrlCreateEdit("test", 10, 620,1180, 80,$ES_AUTOHSCROLL + $WS_VSCROLL + $ES_READONLY)

And i am writing things to the edit by reading out what is there all ready, and pasting on a new line.

Like this:

$test = GuiCtrlRead($loggedit)

$GuiCtrlSetData($loggedit, $test & @CRLF & "new lines..."

How can i get it to automatic scroll down when it is filled with text?

Link to comment
Share on other sites

  • Moderators

Harabo,

Just use _GUICtrlEdit_AppendText and it scrolls on its own: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#Include <GuiEdit.au3>

$hGUI = GUICreate("Test", 500, 500)

$hEdit = GUICtrlCreateEdit("", 10, 10, 480, 200, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY))

$hButton = GUICtrlCreateButton("Add Line", 10, 250, 80, 30)

GUISetState()

$iNextLine = 1

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            _GUICtrlEdit_AppendText($hEdit, "This is Line " & $iNextLine & @CRLF)
            $iNextLine += 1
    EndSwitch

WEnd

By the way, note the use of BitOR to combine styles - the Setting Styles tutorial in the Wiki explains why you should do it this way. :P

All clear? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Harabo,

Just use _GUICtrlEdit_AppendText and it scrolls on its own: :P

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#Include <GuiEdit.au3>

$hGUI = GUICreate("Test", 500, 500)

$hEdit = GUICtrlCreateEdit("", 10, 10, 480, 200, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY))

$hButton = GUICtrlCreateButton("Add Line", 10, 250, 80, 30)

GUISetState()

$iNextLine = 1

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            _GUICtrlEdit_AppendText($hEdit, "This is Line " & $iNextLine & @CRLF)
            $iNextLine += 1
    EndSwitch

WEnd

By the way, note the use of BitOR to combine styles - the Setting Styles tutorial in the Wiki explains why you should do it this way. :D

All clear? :)

M23

Thanks :) It did work perfect!
Link to comment
Share on other sites

  • Moderators

Harabo,

Good. :)

But when you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

Harabo,

Tried with GUICtrlSetColor() but that didnt work

Then you used it incorrectly - do this:

$hEdit = GUICtrlCreateEdit("", 10, 10, 480, 200, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY))
GUICtrlSetColor($hEdit, 0xFF0000)

That gives me red text. :)

If you want different colours for different lines, then you need a RichEdit control - or you can use something like this that I wrote a while ago. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...