Jump to content

scrolling automatically in a GUI edit


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 year later...

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
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...