Jump to content

Richedit horizontal scroll right arrow problem


Go to solution Solved by pixelsearch,

Recommended Posts

Sometimes not giving up succeeds.

I have found what the problem was why I could't get the nScrollCode working.
After downloading the last GuiRichEdit.au3 3.3.16.1 the nScrollCode get values.

So I have changed my script concerning detecting the mouse on right horizontal scroll arrow:

GUIRegisterMsg($WM_NOTIFY, "ON_WINDOW_EDIT_NOTIFY")

Func ON_WINDOW_EDIT_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Local $hWndFrom, $iCode, $tMsgFilter, $tNMHDR, $nScrollCode

    #forceref $hWnd, $iMsg, $wParam

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hRichEdit
            Switch $iCode
                Case $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)

                    Switch DllStructGetData($tMsgFilter, "msg")
                        Case $WM_HSCROLL
                            $nScrollCode = _WinAPI_LoWord(DllStructGetData($tMsgFilter, "wParam"))

                            WindowEditHorizontalArrowWorkAround($nScrollCode)

                            Return 0
                    EndSwitch
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>ON_WINDOW_EDIT_NOTIFY

Func WindowEditHorizontalArrowWorkAround($nScrollCode)
    Local $aPosMouse, $iPosScrollCurrent, $iPosScrollMax, $iWidthScrollArrow, $tSCROLLBARINFO

    $iWidthScrollArrow = _WinAPI_GetSystemMetrics($SM_CXHSCROLL)

    $tSCROLLBARINFO = _GUIScrollBars_GetScrollBarInfoEx($hRichEdit, $OBJID_HSCROLL)
    $iPosScrollMax = $tSCROLLBARINFO.Right - $iWidthScrollArrow - $tSCROLLBARINFO.Left

    $iPosScrollCurrent = _GUIScrollBars_GetScrollBarXYThumbBottom($hGlo_WE_Control, $OBJID_HSCROLL)

    If $iPosScrollCurrent = $iPosScrollMax Then
        If $nScrollCode = $SB_LINERIGHT And _IsPressed("01") Then
            While _IsPressed("01")
            WEnd

            $aPosMouse = MouseGetPos()

            _WinAPI_ShowCursor(False)
            MouseClick($MOUSE_CLICK_LEFT, $aPosMouse[0] - $iWidthScrollArrow, $aPosMouse[1])
            MouseMove($aPosMouse[0], $aPosMouse[1], 1)
            _WinAPI_ShowCursor(True)
        EndIf
    EndIf
EndFunc   ;==>WindowEditHorizontalArrowWorkAround

Sorry pixelsearch for the inconvenience.
BTW Now your script also works fine.

Thanks for patience and ideas.

Cheers mike

   
Edited by mike1950r
Link to comment
Share on other sites

Glad you made it :)
I'm at my bro's home today, writing this from my sister in law computer. I brought with me a USB key containing :
* my script
* the portable AutoIt version 3.3.16.1

I ran the script on her WIN11 computer and it was ok. Though the initial bug is not present on this computer, all nscrollcodes appeared correctly under Windows 11
A little remark : though the calculated maximum scroll position showed 262 (and the width of the scroll arrow shows 17), I couldn't scroll more than 261 on this Win11 computer, no big deal. The deactivated right scroll arrow is awfully grey and nearly looks like it is active (after having forced the maximum scroll position to 261 in the formula)

Yesterday, at home, I tried to do same with an Edit control but I didn't succeed. The only notification you get when you horizontally scroll with an Edit control is $EN_HSCROLL in WM_COMMAND. Of course you can retrieve what's in the scroll structures while you're in WM_COMMAND (EN_CODE) but I don't think you can retrieve all nscrollcodes while horizontally scrolling in an Edit control (I hope I'm wrong on that one).

I wish there was an example in the help file, based on my script, that shows clearly how it is possible to retrieve all nscrollcodes while scrolling from a RichEdit control, without the use of  _GUIScrollBars_Init 

Edited by pixelsearch
Link to comment
Share on other sites

Hi pixelsearch,

yes I'm also glad.
Such a stupid thing not looking for the right richedit library.

In my script I do not use the deactivation of the arrow key anymore.
With the While WEnd loop this is no more necessary (since I make a click on the slider bar afterwards to reset the right max position)
On the working arrows like left horizontal scroll arrow it is also not greyed when you reach the zero position.

I wonder, if there exists a command to click once on the slider (what I do with mouse in my script)
But I did not find anything yet.

Anyway,
the workaround is done and is functional.
Ofcourse it would be better to find the reason for this bug and resolve it.

Thanks lot for your support.

Cheers mike

Link to comment
Share on other sites

Mike, I think a couple of things could be improved in your script :
* $iWidthScrollArrow should be calculated only once, not dozen of times as now. Maybe a Local Static could do that.
* $iPosScrollMax got always the same value, until the RichEdit control is resized. So here again, one has to think if there's a better place to (re)define this variable. Actually it will be recalculated constantly while scrolling and the same result will be returned, unless the richedit control is resized. Maybe placing it in a separate function would help, this function being called once at the beginning of the script, then called again from the resize function (assuming nearly all scripts dealing with a richedit control will need a resize function)

Just quick thoughts, no big deal as it's working fine now.

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