Sign in to follow this  
Followers 0
theguy0000

scrolling automatically in a GUI edit

8 posts in this topic

I have a GUI Edit, but the amount of text inside it often gets larger than the size of the edit. Yes, the user could just scroll down. But is there any possible way to make it automatically scroll down when the amount of text gets too big?


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

In the file GUIEdit.au3:

;===============================================================================
;
; Description:          _GUICtrlEditScroll
; Parameter(s):     $h_edit - controlID
;                           $i_direct - Specifies the action the scroll bar is to take.
; Requirement:          None
; Return Value(s):  If successful, the high-order word of the return value is TRUE, and the low-order word is the number of lines that the command scrolls.
;                           If the $i_direct parameter specifies an invalid value, the return value is FALSE.
; User CallTip:     _GUICtrlEditScroll($h_edit, $i_direct) Scrolls the text vertically in a multiline edit control. (required: <GuiEdit.au3>)
; Author(s):            Gary Frost (custompcs@charter.net)
; Note(s):              $i_direct
;                               This parameter can be one of the following values.
;                                   $SB_LINEDOWN
;                                       Scrolls down one line.
;                                   $SB_LINEUP
;                                       Scrolls up one line.
;                                   $SB_PAGEDOWN
;                                       Scrolls down one page.
;                                   $SB_PAGEUP
;                                       Scrolls up one page.
;                                   $SB_SCROLLCARET
;                                       Scrolls the caret into view
;
;                           To scroll to a specific line or character position, use the _GUICtrlEditLineSscroll.
;
;===============================================================================
Func _GUICtrlEditScroll($h_edit, $i_direct)
   If IsHWnd($h_edit) Then
      Local $a_ret
      If $i_direct == $SB_SCROLLCARET Then
         $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_edit, "int", $EM_SCROLLCARET, "int", 0, "int", 0)
      Else
         $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_edit, "int", $EM_SCROLL, "int", $i_direct, "int", 0)
      EndIf
      Return $a_ret[0]
   Else
      If $i_direct == $SB_SCROLLCARET Then
         Return GUICtrlSendMsg($h_edit, $EM_SCROLLCARET, 0, 0)
      Else
         Return GUICtrlSendMsg($h_edit, $EM_SCROLL, $i_direct, 0)
      EndIf
   EndIf
EndFunc ;==>_GUICtrlEditScroll

Or, the default styles for GUICtrlCreateEdit contain [default ( -1) : $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL]. The autovscroll and autohscroll will scroll the edit as you type.

Edited by greenmachine

Share this post


Link to post
Share on other sites

For $Line_Count = 1 To _GUICtrlEditGetLineCount ($Edit)
     _GUICtrlEditScroll ($Edit, $SB_LINEDOWN)
    Next


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

gafrost's way did the trick. I should have mentioned that the edit was disabled and is only being updated via GUICtrlSetData, so $ES_AUTOVSCROLL didn't work.

thanks


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

Being disabled definitely makes a difference. Here's another method:

_GUICtrlEditLineScroll ($EditName, 0, _GUICtrlEditGetLineCount ($EditName))

I believe it is nearly the same as gafrost's method, it just uses a single line.

Share this post


Link to post
Share on other sites

I know it's an old subject but GaFrost's way scrolls the text really fast ..

so how to slow it down .. when i use sleep (100) in the for next loop to slow it down then my buttons are not responding anymore until the scroll has finished ..

how to bypass this ??

Thnx

Emiel


Best regards,Emiel Wieldraaijer

Share this post


Link to post
Share on other sites

I know it's an old subject but GaFrost's way scrolls the text really fast ..

so how to slow it down .. when i use sleep (100) in the for next loop to slow it down then my buttons are not responding anymore until the scroll has finished ..

how to bypass this ??

Thnx

Emiel

Instead of Sleep() use TimerInit()/TimerDiff() to control the timing:

$Timer_1 = TimerInit()

While 1

; Get other stuff done...

If TimerDiff($Timer_1) > 100 Then

_GUICtrlEditScroll ($Edit, $SB_LINEDOWN)

$Timer_1 = TimerInit()

EndIf

WEnd

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

@PsaltyDS

thnx

for the explaination .. it works..

I keep learning ..

Emiel


Best regards,Emiel Wieldraaijer

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
Sign in to follow this  
Followers 0