Jump to content

How to catch event scrolling in _GUICtrlRichEdit


tkminh
 Share

Recommended Posts

A RichEdit control does not appear to have any notifications related to scrolling.

You could send EM_GETSCROLLPOS to monitor the scroll position in a loop.

:graduated:

Edit: Uhmm... see demo below.

:(

Edited by PsaltyDS
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

A RichEdit control does not appear to have any notifications related to scrolling.

You could send EM_GETSCROLLPOS to monitor the scroll position in a loop.

:graduated:

Rich Edit: Supported in Microsoft Rich Edit 1.0 and later. To receive EN_VSCROLL notification codes, specify ENM_SCROLL in the mask sent with the EM_SETEVENTMASK message. For information about the compatibility of rich edit versions with the various system versions, see About Rich Edit Controls.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Oh, all right then, a guy can be wrong already! :graduated:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiRichEdit.au3>

Global $sText = "", $hGui, $hRichEdit

For $n = 2 To 100
    $sText &= $n & " - This is a single long line intended to cause a hoizontal scroll bar to appear in my RichEdit control." & @CRLF
Next
$hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, $sText, 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $WS_HSCROLL))
_GUICtrlRichEdit_SetEventMask($hRichEdit, BitOR($ENM_SCROLL, $ENM_SCROLLEVENTS))
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")


While True
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _GUICtrlRichEdit_Destroy($hRichEdit)
            Exit
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam)
    ; $tagEN_MSGFILTER = hwnd hWndFrom;uint_ptr IDFrom;INT Code;uint msg;wparam wParam;lparam lParam
    #forceref $iMsg, $iWparam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $iLparam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagEN_MSGFILTER, $iLparam)
                    $aPos = _GUICtrlRichEdit_GetScrollPos($hRichEdit)
                    Switch DllStructGetData($tMsgFilter, "msg")
                        Case 276
                            ConsoleWrite("Debug: Horz Scroll: x = " & $aPos[0] & "; y = " & $aPos[1] & @LF)
                        Case 277
                            ConsoleWrite("Debug: Vert Scroll: x = " & $aPos[0] & "; y = " & $aPos[1] & @LF)
                    EndSwitch
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

:(

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