Jump to content

Gesture support in Melba's Scrollbars UDF


Melba23
 Share

Recommended Posts

  • Moderators

Qwerty212,

After a disastrous attempt to split the relevant posts from the UDF thread which nearly brought down the forum and resulted in the posts being lost forever, I am starting this new thread to renew the discussion outside the UDF thread itself.

For new readers, Qwerty212 wants to get touchscreen gesture support in my Scrollbars UDF - the lost posts were basically discussing what his touchscreen did (scroll when the scrollbars were swiped) and did not do (scroll when the control/GUI was swiped) and some code snippets seeing what messages were being generated. Everything is complicated by the fact that I do not have as touchscreen on which to test!

Here is a new version of the test code which produces some console output. Can you please swipe away and then let me have a description of what exactly you did, what happened to the GUI, and the relevant output from SciTE:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

#include "GUIScrollbars_Ex.au3"

Global Const $tagGESTUREINFO = "UINT cbSize; DWORD dwFlags; DWORD dwID; HWND hwndTarget; short X; short Y; DWORD dwInstanceID; DWORD dwSequenceID; UINT64 ullArgumengs; UINT cbExtraArgs"
Global $tGesInfo = DllStructCreate($tagGESTUREINFO)
DllStructSetData($tGesInfo, "cbSize", DllStructGetSize($tGesInfo))
Global $pGesInfo = DllStructGetPtr($tGesInfo)

Global $aDirn[5] = ["", "UP", "DOWN", "LEFT", "RIGHT"]

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

$cLabel = GUICtrlCreateLabel("", 0, 0, 1000, 1000)
GUICtrlSetState($cLabel, $GUI_DISABLE)
$sData = ""
For $i = 1 To 74
    If StringRight($i, 1) = 0 Then
        $sData &= "Line " & $i & " "
        For $j = 1 to 13
            $sData &= "Extended line "
        Next
        $sData &= @CRLF
    Else
        $sData &= "Line " & $i & @CRLF
    EndIf

Next
GUICtrlSetData($cLabel, $sData)

GUISetState()

_GUIScrollbars_Generate($hGUI, 1000, 1000)

GUIRegisterMsg($WM_GESTURE, "_WM_GESTURE")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch

WEnd

Func _WM_GESTURE($hWnd, $Msg, $wParam, $lParam)

    Local $iX_1, $iY_1, $iX_2, $iY_2, $bPanning = False

    DllCall("User32.dll", "BOOL", "GetGestureInfo", "HANDLE", $lParam, "struct*", $pGesInfo)

    Switch DllStructGetData($tGesInfo, "dwID")
        Case 1
            ; Gesture started
            $iX_1 = DllStructGetData($tGesInfo, "X")
            $iY_1 = DllStructGetData($tGesInfo, "Y")
            ConsoleWrite("+ Gesture started" & @CRLF)
        Case 2
            ; Gesture ended - still scroll if panning
            If $bPanning Then
                ; Clear flag
                $bPanning = False
                ; Get final position
                $iX_2 = DllStructGetData($tGesInfo, "X")
                $iY_2 = DllStructGetData($tGesInfo, "Y")
                ; Scroll to final position
                __GestureScroll(DllStructGetData($tGesInfo, "hwndTarget"), $iX_1, $iY_1, $iX_2, $iY_2)
                ConsoleWrite("! Gesture ended" & @CRLF)
            EndIf

        Case 4
            ; Set panning flag
            $bPanning = True
            ; Get current position
            $iX_2 = DllStructGetData($tGesInfo, "X")
            $iY_2 = DllStructGetData($tGesInfo, "Y")
            ; Scroll as required
            __GestureScroll(DllStructGetData($tGesInfo, "hwndTarget"), $iX_1, $iY_1, $iX_2, $iY_2)
            ; Set base for next call
            $iX_1 = $iX_2
            $iY_1 = $iY_2
            ConsoleWrite("- Gesture continued" & @CRLF)

    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc   ;==>_WM_GESTURE

Func __GestureScroll($hWnd, $iX_1, $iY_1, $iX_2, $iY_2)

    Local $iDirn

    ; Find window index
    Local $iIndex = -1
    For $i = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $hWnd = $__g_aSB_WindowInfo[$i][0] Then $iIndex = $i

    Next

    If $i <> -1 Then
        ; Calculate lines to scroll
        Local $iX_Diff = Int(($iX_2 - $iX_1) / $__g_aSB_WindowInfo[$iIndex][2])
        $iDirn = (($iX_Diff > 0) ? ($SB_LINELEFT) : ($SB_LINERIGHT))
        ConsoleWrite("X scroll " & $iX_Diff & " lines" & @CRLF)
        For $i = 1 To Abs($iX_Diff)
            ; Scroll
            _SendMessage($hWnd, $WM_HSCROLL, $iDirn)
        Next
        ; Calculate lines to scroll
        Local $iY_Diff = Int(($iY_2 - $iY_1) / $__g_aSB_WindowInfo[$iIndex][3])
        $iDirn = (($iY_Diff > 0) ? ($SB_LINEDOWN) : ($SB_LINEUP))
        ConsoleWrite("Y scroll " & $iY_Diff & " lines" & @CRLF)
        For $i = 1 To Abs($iX_Diff)
            _SendMessage($hWnd, $WM_VSCROLL, $iDirn)
        Next

    EndIf

EndFunc

If anyone else wants to join in the fun, then please do.

M23

Edited by Melba23
Fixed code

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

TheDcoder,

Thanks.

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

Hi Melba, sorry for the delay.

I've tested your last script.

I've tried first to swipe from down to up (like you want to scroll down with a touch screen)

Even with a very small movement of the finger the GUI scrolls to the bottom.

This is what I get in the console:

+Gesture started
x scroll 71 lines
Y scroll 24 lines
-Gesture continued

 1.png

 The image is from some other tests, so coordinates may differ, but the result is the same.

 

Then I tried to scroll up doing a swipe from the upper part of the GUI to the lower one.

+Gesture started
x scroll 68 lines
Y scroll 9 lines
-Gesture continued
+Gesture started
x scroll 68 lines
Y scroll 16 lines
-Gesture continued
+Gesture started
x scroll 68 lines
Y scroll 23 lines
-Gesture continued

Nothing happens. Neither the GUI content or the verticall scrollbar make any movement.

 

If I try to scroll up or down (even I'm on the bottom of the GUI) the scrollbar makes some tiny movement up and the content fades to the upper side of the GUI (like if it is scrolling even more to down). As my English sucks I'll show an image to try to explain my self a little bit:

7.png

If that happens and I try to scroll up directly moving the scrollbar then I just can not reach the top of the lines:

2.png 

 

Tryng to scroll repeatedly can drive to get all the content outside the screen:

28544.jpg

Trying to swipe horizontally doesn't trigger any event in the console or any scrolling in the GUI.

I hope it helps.

Greets from Barcelona

Edited by Qwerty212
Link to comment
Share on other sites

  • Moderators

Qwerty212,

Thanks for that very comprehensive report - something to keep me occupied over the weekend when I am not flying!

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